Imgur API Version 3
API Status
Status for the API can be found at status.imgur.com!
Overview
Imgur's API exposes the entire Imgur infrastructure via a standardized programmatic interface. Using Imgur's API, you can do just about anything you can do on imgur.com, while using your programming language of choice.
The Imgur API is a RESTful API based on HTTP requests and XML or JSON(P) responses. If you're familiar with the APIs of Twitter, Amazon's S3, del.icio.us, or a host of other web services, you'll feel right at home.
This version of the API, version 3, uses OAuth 2.0. This means that all requests will need to be encrypted and sent via SSL/TLS to https://. It also means that you need to register your application, even if you aren't allowing users to login.
Example code
These examples serve as a starting point to help familiarize you with the basics of the Imgur API.
Need help?
The Imgur engineers are always around answering questions. Send your questions to api@imgur.com.
Register an Application (IMPORTANT)
Each client must register their application and receive the client_id and client_secret.
For public read-only and anonymous resources, such as getting image info, looking up user comments, etc. all you need to do is send an authorization header with your client_id in your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account), or if you'd like to create an anonymous album. This lets us know which application is accessing the API.
Authorization: Client-ID YOUR_CLIENT_ID
Commercial Usage
Your application is commercial if you're making any money with it (which includes in-app advertising), if you plan on making any money with it, or if it belongs to a commercial organization.
To use Imgur's API commercially, you must first register your application. Once that's done, you must register with Mashape. Mashape allows you to choose a pricing plan that fits your needs. From then on, the API endpoint is https://imgur-apiv3.p.mashape.com/ which must be used in replace of https://api.imgur.com/. Additionally, you must set a X-Mashape-Key request header with the key obtained from Mashape.
Free Usage
The Imgur API is free for non-commercial usage. Your application is probably free if you don't plan on making any money with it, or if it's open source.
Endpoints
The API is accessed by making HTTP requests to a specific version endpoint URL, in which GET or POST variables contain information about what you wish to access. Every endpoint is accessed via an SSL-enabled HTTPS (port 443), this is because everything is using OAuth 2.0.
Everything (methods, parameters, etc.) is fixed to a version number, and every call must contain one. Different Versions are available at different endpoint URLs. The latest version is Version 3.
The stable HTTP endpoint for the latest version is:
https://api.imgur.com/3/
The previous versions can still be accessed if you use the API version number at the end of the default endpoint. However, these previous versions are no longer supported, so if you find a bug, we're going to ask that you move to the latest version.
Responses
Each response is wrapped in a data tag. This means if you have a response, it will always be within the data field. We also include a status code and success flag in the response. For more information and examples go to the data models page.
Responses are either JSON (the default), JSONP, or XML. Response formats are specified by supplying an extension to the API call. For example, if you want to access the gallery information with JSON:
https://api.imgur.com/3/gallery.json
JSONP responses are made by adding the callback parameter via either GET or POST to the request. For example:
https://api.imgur.com/3/gallery.json?callback=function_name
and to specify an XML response, the URL is:
https://api.imgur.com/3/gallery.xml
Paging Results
For the most part, if the API action is plural, you can page
it via a query string parameter.
NOTE: /gallery endpoints do not support the perPage query
string, and /album/{id}/images is not paged.
Query String Parameter | Required | Description |
page | optional | Page number of the result set (default: 0) |
perPage | optional | Limit the number of results per page. (default: 50, max: 100) |
Example:
https://api.imgur.com/3/account/imgur/images/0.json?perPage=42&page;=6
Authentication
The API requires each client to use OAuth 2 authentication. This means you'll have to register your application, and generate an access_code if you'd like to log in as a user.
For public read-only and anonymous resources, such as getting image info, looking up user comments, etc. all you need to do is send an authorization header with your client_id in your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account), or if you'd like to create an anonymous album. This lets us know which application is accessing the API.
Authorization: Client-ID YOUR_CLIENT_ID
For accessing a user's account, please visit the OAuth2 section of the docs.
OAuth Endpoints
To access OAuth, the following endpoints must be used:
- https://api.imgur.com/oauth2/addclient
- https://api.imgur.com/oauth2/authorize
- https://api.imgur.com/oauth2/token
You can also verify your OAuth 2.0 tokens by setting your header and visiting the page https://api.imgur.com/oauth2/secret
Rate Limits
The Imgur API uses a credit allocation system to ensure fair distribution of capacity. Each application can allow approximately 1,250 uploads per day or approximately 12,500 requests per day. If the daily limit is hit five times in a month, then the app will be blocked for the rest of the month. The remaining credit limit will be shown with each requests response in the X-RateLimit-ClientRemaining HTTP header.
We also limit each user (via their IP Address) for each application, this is to ensure that no single user is able to spam an application. This limit will simply stop the user from requesting more data for an hour. We recommend that each application takes precautions against spamming by implementing rate limiting on their own applications. Each response will also include the remaining credits for each user in the X-RateLimit-UserLimit HTTP header.
Each request contains rate limit information in the HTTP response headers.
HTTP Header | Description |
X-RateLimit-UserLimit | Total credits that can be allocated. |
X-RateLimit-UserRemaining | Total credits available. |
X-RateLimit-UserReset | Timestamp (unix epoch) for when the credits will be reset. |
X-RateLimit-ClientLimit | Total credits that can be allocated for the application in a day. |
X-RateLimit-ClientRemaining | Total credits remaining for the application in a day. |
Unless otherwise noted, an API call deducts 1 credit from your allocation. However, uploads have a significantly higher computational cost on our back-end, and deduct 10 credits per call. All OAuth calls, such as refreshing tokens or authorizing users, do not deduct any credits.
You can also check the current rate limit status on your application by sending a GET request to https://api.imgur.com/3/credits
Your use of the Imgur API is also limited by the number of POST requests your IP can make across all endpoints. This limit is 1,250 POST requests per hour. Commercial Usage is not impacted by this limit. Each POST request will contain the following headers.
HTTP Header | Description |
X-Post-Rate-Limit-Limit | Total POST credits that are allocated. |
X-Post-Rate-Limit-Remaining | Total POST credits available. |
X-Post-Rate-Limit-Reset | Time in seconds until your POST ratelimit is reset |