CMS Development

matteo
Miembro

API Blog listing based on tag

resolver

Hi everyone,

 

we are implelenting a blog stream in a client's website therefore we are using API cURL call 

 

https://api.hubapi.com/content/api/v2/blog-posts?hapikey=demo&updated__gt=1430452800000&content_group_id=351076

 

we are facing an issue: blog post have been tagged with several tags, such as News, Events or other marketing tags.

 

what we are trying to make out is if there's a way to list ONLY posts tagged with specific single keyword such as NEWS.

 

thank you!

0 Me gusta
1 Soluciones aceptada
tjoyce
Solución
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

API Blog listing based on tag

resolver

@matteo - Unfortuanately, you cannot query the API with a blog topic name. However, you can use the topics api endpoint to get the topics that you need to query, which will get the relative ID to that topic. Then, you can pass a parameter of topic_id= to your blog post listing API call.

example: 

https://api.hubapi.com/content/api/v2/blog-posts?hapikey=demo&topic_id=53100784


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

Ver la solución en mensaje original publicado

0 Me gusta
4 Respuestas 4
tjoyce
Solución
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

API Blog listing based on tag

resolver

@matteo - Unfortuanately, you cannot query the API with a blog topic name. However, you can use the topics api endpoint to get the topics that you need to query, which will get the relative ID to that topic. Then, you can pass a parameter of topic_id= to your blog post listing API call.

example: 

https://api.hubapi.com/content/api/v2/blog-posts?hapikey=demo&topic_id=53100784


If this answer helped, please, mark as solved 😄


tim@belch.io | forms.belch.io | Design your own Beautiful HubSpot Forms; No coding necessary.

 

Drop by and say Hi to me on slack.

0 Me gusta
MFall13
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

API Blog listing based on tag

resolver

@tjoyce is it possible to pass multiple topic id values to the same topic_id query parameter? 

 

Something like &topic_id=xxxxxxxx&xxxxxxxx OR &topic_id=xxxxxxxx&topic_id=xxxxxxxx ?

0 Me gusta
tjoyce
Experto reconocido | Partner nivel Elite
Experto reconocido | Partner nivel Elite

API Blog listing based on tag

resolver

Hi @MFall13 - I have not tried to search multiple topics before but perhaps the double underscore query might be something you can explore... Something like

&topic_ids__in=10945,28906

However, I suspect something like this might return only posts that appear in both topics... might need some guess work done around this

 

Optional query string filters & options
Some parameters support "range" filters via double-underscored param suffixes, like '__gt'. If a parameter supports a filter type of 'gt', that means you can append a double-underscore and 'gt' to the parameter name to find all items greater than a specified value.

For example, the following query will find all items with the 'updated' time greater than 1364424600000: https://api.hubapi.com/blogs/v3/topics?hapikey=demo&created__gt=1364424600000
MFall13
Colaborador | Partner nivel Platinum
Colaborador | Partner nivel Platinum

API Blog listing based on tag

resolver

 

@tjoyce thanks for the suggestion. I feel like I've tried every value filter combo out there. 

&topic_ids__in=30111149151,32404273845" (and &topic_id__in too)

returns 

Invalid query Filtering by \"topic_id(s) in\" is not allowed

 

... another try with the following exact params:

&topic_id=30111149151&topic_id=32404273845

responds with a valid request, but only pulls in blogs with the first topic id

 

...and another try with the suffix '__contains' to no avail.

 

Any other suggestions? Much appreciated!

 

0 Me gusta