pythonrestinsomnia

Unsplash API - Access specific photo by id


I want to access a specific photo via the Unsplash API and a given photo ID. Unfortunately my approaches didn't succeed and it seems that no other person on google tried it yet.

Prerequisite

Unsplash API Documentation

As stated here:

Endpoint: https://api.unsplash.com/

GET /photos/:id

Provide as a parameter the photo's id as well as your access key:

My full GET string:

https://api.unsplash.com/photos/:id?id=nDV6ahWLvEg&client_id=123123123123

Error Response

I always get an 404 - Couldn't find photo. Authorization works, tried this with other unsplash endpoints. Tried to access it via python ´request` package and Insomnia (REST Client), both the same error. Tried also the "collections endpoint" who also needs an id (collection id) - error 404.

I assume that I do something wrong with the :id ? id = ...


Has anybody an idea?


Solution

  • RESTful API can make use of different types of parameters, e.g.

    The Unsplash API makes use of both types of parameters. client_id is a query parameter while id is a path parameter. You can recognize this by the colon (:) used in the documentation (/photos/:id).

    Thus you must replace :id with the actual photo id. You request looks then like:

    https://api.unsplash.com/photos/nDV6ahWLvEg?client_id=YOUR_ACCESS_KEY