Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

349
Views
Twitter API - How to check if a specific user liked a specific tweet?

I'm using the twitter v2 API for node, I can pull all users who liked a twitter and use an if in a loop, to check if the user I want is inside the array, but depending on if the tweet has many likes the loop it becomes too long.

I would like to know if there is a way to go straight to the information without needing the loop, if there is any filter or something.

    const client = twitterApi({ token, secret })
    const usersLiked = await client.v2.tweetLikedBy(target, {
      asPaginator: true,
    })

    for await (const user of usersLiked) {
      if (user.id === userIdTwitter) {
        await task.related('users').attach([userId])
        return response.ok({})
      }
    }

    return response.notFound()

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The binary search might help you in this situation. Binary search is a search algorithm that divide the search making it faster witch is better than looking and comparing one by one. An import detail is that this array should be in ascending order before searching. I hope I have been helpful somehow.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!