XF 2.1 How to get a thread url from XF Api ?

djgxp

New member
Trying to play a little bit with the API, I could see JSON thread documents with posts and so on but I didn't see anything like a canonical url of the thread or even a path that would allow me to recreate the thread URL from an external site.

So did I miss something or this is something that we can't do yet with the API ?

More than that, for additional fields that would be added by an addon, is there any way to retrieve its value from the API or get an item using this additional field ?
For Example, I have an additional field called "migration_old_thread_id", would it be possible to use it on the API with a query string or whatever to get my thread ?
 

Sim

Well-known member
Trying to play a little bit with the API, I could see JSON thread documents with posts and so on but I didn't see anything like a canonical url of the thread or even a path that would allow me to recreate the thread URL from an external site.

So did I miss something or this is something that we can't do yet with the API ?
XenForo URLs are consistent and based on the base_url of the site.

For example, the base URL of this site is https://xenforo.com/community and this thread can always be found at https://xenforo.com/community/threads/162368 - no need to include all the other URL info, that is subject to change if the thread title changes, only the ID is relevant.

Similarly for most other elements of the forum: members can be found at {base_url}/members/{id}, forums at {base_url}/forums/{id}, etc.

No, it's not canonical - but the forum will automatically redirect you to the canonical URL provided you give it a valid ID.

If you already know the API URL, you can probably work out the Base URL for yourself, but either way - the base_url is accessible from the index endpoint.
 

djgxp

New member
Similarly for most other elements of the forum: members can be found at {base_url}/members/{id}, forums at {base_url}/forums/{id}, etc.
Actually I know that I can build manually the urls but from an SEO point of view it would have been great to be able getting friendly urls instead of partial urls leading to 301 redirects.

Thanks anyway for your answer, I'll probably extend things in XF to get what I want ;)
 

DWilly

Member
This is wildly friendly for pulling information from XF into other parts of the website that are not XF. Especially when combined with creating some simple views in the XF database.

Is there a simple way to get an avatar image using the members ID?
 
Top