Skip to content

Instantly share code, notes, and snippets.

@optlsnd
Created June 5, 2019 10:58
Show Gist options
  • Save optlsnd/17cf31200742906a9a29d389c450b2e8 to your computer and use it in GitHub Desktop.
Save optlsnd/17cf31200742906a9a29d389c450b2e8 to your computer and use it in GitHub Desktop.
const axios = require('axios') // needs to be installed with "npm i axios --save"
const PUBLIC_KEY = 'your_public_key_here'
const SECRET_KEY = 'your_secret_key_here'
const endpoint = 'https://api.uploadcare.com/files/?limit=1000&removed=false'
const config = {
headers: {
"Authorization": `Uploadcare.Simple ${PUBLIC_KEY}:${SECRET_KEY}`
}
}
const files = []
function getData(url) {
axios.get(url, config).then(res => {
files.push(...res.data.results)
console.log(`${files.length} of ${res.data.total}`)
if (res.data.next !== null) {
getData(res.data.next)
} else {
files.forEach(file => {
if (file.original_filename.indexOf('15314') !== -1) { // replace 14314 with your query string
console.log(file.uuid)
}
})
}
})
}
getData(endpoint)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment