tumblr.js
The official JavaScript client library for the Tumblr API. Check out the detailed documentation here.
Installation
Install this package from npm:
npm install --save tumblr.jsUsage
Authentication
Different API methods use different kinds of authentication.
Most of them require at least an API key, which will require you to register an application. The OAuth Consumer Key is your API key.
For methods that require a fully signed request, you'll need OAuth tokens as well, which you get from authenticating as a Tumblr user and allowing access to your API application. Here's the easy way to do it with our own account:
- Visit the OAuth applications page
- Click "Explore API" on the application you want to authorize
- Click the "Allow" button, which will take you to the API console
- Click the "Show keys" button, which will show you the credentials you can use to make signed requests.
If you're building an application of your own for users out in the world, you'll need to go through the 3-legged OAuth flow. See the help docs for more info.
In Node.js
const tumblr = ;const client = tumblr;Or, if you prefer:
const tumblr = ;const client = // ...;The request methods return Request objects by default, but you can have it return Promise objects instead, if that's more your thing. Pass returnPromises: true in the options to createClient:
const tumblr = ;const client = tumblr;In the Browser
Due to CORS restrictions, you're going to have a really hard time using this library in the browser. Although GET endpoints on the Tumblr API support JSONP, this library is not intended for in-browser use. Sorry!
Example
// Show user's blog namesclient;Supported Methods
Below is a list of available methods and their purpose. Available options are documented in the API Docs and are specified as a JavaScript object.
client;In most cases, since options are optional (heh) they are also an optional argument, so there is no need to pass an empty object when supplying no options, like:
client;If you're using Promises, use then and/or catch instead of a callback:
client ;User Methods
// Get information about the authenticating user & their blogsclient; // Get dashboard for authenticating userclient;client; // Get likes for authenticating userclient;client; // Get followings for authenticating userclient;client; // Follow or unfollow a given blogclient;client; // Like or unlike a given postclient;client;Blog Methods
// Get information about a given blogclient; // Get a list of posts for a blog (with optional filtering)client;client; // Get the avatar URL for a blogclient;client; // Get the likes for a blogclient;client; // Get the followers for a blogclient;client; // Get the queue for a blogclient;client; // Get the drafts for a blogclient;client; // Get the submissions for a blogclient;client;Post Methods
// Edit a given postclient; // Reblog a given postclient; // Delete a given postclient; // Convenience methods for creating post typesclient;client;client;client;client;client;client;Tagged Methods
// View posts tagged with a certain tagclient;client;Unsupported Methods
You can make GET and POST requests to any endpoint directly. These methods are used internally by the methods listed above:
// GET requestsclient; // POST requestsclient;In the unlikely event that we add a bunch of methods to the API docs and don't update this client, you can map new client methods to API endpoints. URL and query parameters are automatically turned into arguments to these methods. It's a little weird to explain, so just look at these examples:
// GET methodsclient; // POST methodsclient;Running Tests
npm test # linter and tests npm run lint # linter npm run mocha # just the tests Copyright and license
Copyright 2013-2019 Tumblr, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations.