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

173
Views
How to make API call expired/unique and return data once?

I have video site with nodejs as backend. Video is public for everyone so API is also public. This is the problem, they can view API and change params to get more data. I want to protect it from data leaking, spam or crawl.

I want to make each API is unique, each time user send a request, API will return data once. If he visit this API URL again, no data returned. If he refresh page, new API URL is being generated and give him data once. It look like this site https://www.douyin.com/video/7000302017407110436

Data return once only, if you visit below API call URL, it return null like this https://shorturl.at/cwI37

Data showing once like this enter image description here

How do I do this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If I got you right, you would like to send a link to a specific user and this link should only be called once. Here a basic concept:

  • you create a function that creates a unique ID and then you store the unique ID together with the location of the resource. This resource then should not be reachable from outside (not in a public directory)
  • you create a route like FQDN/get/:id where "id" is the unique ID.
  • when handling the request, you search in your storage/DB if you find the unique ID, then you know, where the resource is located. You now need to do two things:
  • invalidate the unique ID (removing it from the storage/DB) and
  • serving the resource from its non pblic location.
  • if the unique ID is no longer in your storage (DB), you just return null

One problem you might need to tackle: e.g. if you type in a certain url in a the browser, it makes a prefetch while you type it. Which means, that there are situations where a link then is called more then one time.

about 4 years ago · Juan Pablo Isaza 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!