Home › Forums › Calendar Products › Events Calendar PRO › JSON Rest API
- This topic has 13 replies, 3 voices, and was last updated 6 years, 7 months ago by Courtney.
-
AuthorPosts
-
June 23, 2014 at 4:27 pm #245481Anthony D’ArcoParticipant
Howdy, we have been playing around with the Rest API to see if we can’t get your information into our app. However, every time we try we seem to only be able to get a list of very general information. We were wondering if the Event Calendar actually works with the API, and if so, is there any documentation on how to get the EC info out of WordPress? I couldn’t find anything when I was using your search tool.
Thank you,
AnthonyJune 23, 2014 at 5:31 pm #245638BarryMemberHi Anthony,
Can you confirm if you’re working through the API added by this plugin (or if you are using develop code for WordPress that hasn’t yet been released in stable form)?
June 23, 2014 at 6:13 pm #245750Anthony D’ArcoParticipantBarry,
I should have been more specific, yes, I am using that plugin.
Thank you,
AnthonyJune 24, 2014 at 12:15 pm #247901BarryMemberOK – well we can’t really guarantee compatibility with other plugins (and haven’t taken any steps to specifically integrate with this one). Are you finding you can work with custom post types and taxonomies generally – ie, are the difficulties you are experiencing specific to The Events Calendar and its own set of post types?
June 24, 2014 at 12:32 pm #247957Anthony D’ArcoParticipantI understand that, and I know this is planning on making it to core at some point. I am able to get into custom post types in general, however its not able to get at some of the more fine-tuned details that the EC has. When we are testing it, we can get it to display the events, but things like start and end times are not available. Does that make sense?
Thank you,
AnthonyJune 24, 2014 at 1:13 pm #248057BarryMemberYes, that makes sense.
The start and end dates for events are actually just stored as post meta data (and a brief skim of their docs suggests post meta is covered, to some extent) – have you investigated working with post meta via this API generally and is it looking like there are specific “gotchas” with event post meta data, for some reason?
July 4, 2014 at 11:28 am #279616Anthony D’ArcoParticipantI apologize for the delay in response. I’ve been super busy/playing around with the rest API and getting the hang of it more and more. I’m not sure exactly what you meant by specific “gotchas,” but this is what I have so far.
Basically, I have been converting wpquery arrays into query strings. When I test the following:
http://hfca.staging.wpengine.com/wp-json/posts?type=hfca-teachers
I get all the information from the post type hfca-teachers as expected, however, when I do the follow:
http://hfca.staging.wpengine.com/wp-json/posts?type=tribe_events
I get a 502 Bad Gateway. That would lead me to believe there is some sort of incompatibility, correct?I have done a lot of other tests, but these two query strings seem as though they would be the most helpful in figuring out what is going on.
Thank you,
AnthonyJuly 4, 2014 at 11:48 am #279690Anthony D’ArcoParticipantI apologize, I found something else out interesting:
so, clearly its not everything in the ECP, for venues:
http://hfca.staging.wpengine.com/wp-json/posts?type=tribe_venue
it worked just fine (Still not showing the meta data, but that is the next step). Is it possible that I have too many events, or something of that nature?Thank you,
AnthonyJuly 4, 2014 at 10:42 pm #283255BarryMemberhttp://hfca.staging.wpengine.com/wp-json/posts?type=tribe_events
I get a 502 Bad Gateway. That would lead me to believe there is some sort of incompatibility, correct?I’m not sure, perhaps something else is conflicting – can you inspect the server error log and check for any pertinent errors … and does this occur in an otherwise default environment (with just the JSON API plugin, our core and PRO plugins and a default, unmodified WordPress theme such as Twenty Thirteen)?
The structure of your URLs interests me – have you further customized things/changed the routing or have you extended the plugin with new controllers of your own? Forgetting the API base for the moment, shouldn’t the latter half of that URL you provided be:
…/get-posts/?post_type=tribe_events
It certainly works for me when I test it locally, but I’m basically just using an “out of the box” configuration which may not be identical to your own.
Is it possible that I have too many events, or something of that nature?
Not impossible, but if so might it be worth setting an additional count parameter in your URL query? Though, as it looks like this defaults to 10, I’m not sure why it would be a problem.
July 5, 2014 at 7:33 am #285757Anthony D’ArcoParticipantAlright, I think this just a lot more interesting. I couldn’t get the rest API to work at all with the default theme (I believe they may have it disabled, based on what I saw in the documentation). So, I setup a new testing environment using Genesis (because that is our base theme on the majority of our sites). It turns out it worked just fine AND it worked for events:
http://testeditor.wpengine.com/wp-json/posts?type=tribe_eventsThere were only two events and they both popped up no problem. So, I am going to reach out to WpEngine to see if they can shed some light on the 502 Error, however that doesn’t solve my second problem, the meta data does not seem to want to appear.
(as a quick side note, I agree the URL structure is a bit off, but the docs say to do it that way, and when you get a response, it actually shows the URL I need, so I’m not creating that each time, it is something I copy and paste with each level I get deeper).
Thank you,
AnthonyJuly 5, 2014 at 7:45 am #285793Anthony D’ArcoParticipantOne last little tidbit. I found the documentation (not a very intuitive place for this, but I found that to retrieve the meta for a post you do the following (so simple its stupid):
http://testeditor.wpengine.com/wp-json/posts/470/metaBut when that is put in I keep getting a 403 Forbidden Error. Thoughts?
Thank you,
AnthonyJuly 6, 2014 at 5:09 am #289526BarryMemberSo, I am going to reach out to WpEngine to see if they can shed some light on the 502 Error
That’s a good idea, especially if it is only occurring in that environment (perhaps they can point you to an error log or otherwise help).
I found that to retrieve the meta for a post you do the following (so simple its stupid):
http://testeditor.wpengine.com/wp-json/posts/470/meta…
But when that is put in I keep getting a 403 Forbidden Error. Thoughts?
I’m not sure, but I’d start by exploring if this is a general issue with the JSON API plugin (does it happen for regular posts with post meta data, or just events) and go from there. Perhaps it’s intentional where the user/agent is accessing the API without having authenticated?
August 26, 2014 at 8:39 am #701621BarryMemberHi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!
September 25, 2017 at 11:18 am #1354409CourtneyMemberHey there
Just posting a quick update that we’ve just launched The Events Calendar – Full REST Support. You can read the release notes at https://theeventscalendar.com/release-events-calendar-full-rest-support/.
We also published a helpful guide: Introduction to The Events Calendar REST API https://theeventscalendar.com/knowledgebase/introduction-events-calendar-rest-api/ .
We’re excited to provide this functionality for you.
Thanks
Courtney 🙂 -
AuthorPosts
- The topic ‘JSON Rest API’ is closed to new replies.