Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda