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. })