Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

183
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda