Getting search results from an user session

Getting search results from an user session

When you call Public endpoints such as the Search endpoint, it will return results from a random unauthenticated session.

If you want to get more uniform results and tailored for a specific user, it is possible to call the endpoint from an user scope by including the X-Account-Key.

Example in Python:
  1. from tikapi import TikAPI

  2. api = TikAPI("yourAPIKey")

  3. api.set(
  4. __options__={
  5. 'params':{
  6. 'accountKey':{
  7. 'name': 'X-Account-Key',
  8. 'help': "The Account Key is invalid.",
  9. 'location': "headers",
  10. 'validate': "^[a-zA-Z0-9]{10,}$"
  11. }
  12. }
  13. }
  14. )

  15. # Just add the  accountKey parameter
  16. api.public.search("autocomplete", "query", accountKey="myOptionalAccountKeyHere")
Example in Javascript:
  1. import TikAPI from 'tikapi';

  2. api = TikAPI("yourAPIKey")

  3. api.set(
  4. $options: {
  5. params:{
  6. accountKey:{
  7. name: 'X-Account-Key',
  8. help: "The Account Key is invalid.",
  9. location: "headers",
  10. validate: "^[a-zA-Z0-9]{10,}$"
  11. }
  12. }
  13. }
  14. )

  15. api.public.search({
  16. category: "autocomplete", 
  17. query: "query", 
  18. accountKey: "myOptionalAccountKeyHere"
  19. })



    • Related Articles

    • How to collect posts for a topic or identify industry trends?

      We have multiple endpoints which you can use in combination in order to collect posts for a specific topic or identify industry trends.  Here are our recommendations on things you can do: Getting feed posts (For You) from an authenticated account ...
    • How to download videos?

      Endpoints for getting posts such as Get feed posts or the Get video information endpoint return the video(s) information in the JSON response object.  You can download the video file using the link at the downloadAddr or playAddr field. Example ...
    • How do I get more than 30 items?

      Usually you can get about 30 items from a API request (excluding the search endpoint which returns 12). This is not a limit set by us, but by TikTok.   In order to collect more items you have to use the iterating parameters, such ...