Find an API

Search public APIs with auth details & Postman guides

← All APIs

Mastodon API

mastodon.social · Social

Social Bearer Token Free & Open Social Microblogging Fediverse

Open-source federated social network API — read timelines, search posts, manage accounts, and post toots. Available on any Mastodon instance. Free, 300 requests/5 minutes.

Authentication

Bearer Token Public timelines require no auth. For posting, create an app at mastodon.social/settings/applications to get an access token.

Sample Requests

GET Get public timeline

Get recent public posts from Mastodon.

https://mastodon.social/api/v1/timelines/public?limit=5

Hover any highlighted part to learn what it does

curl -X GET "https://mastodon.social/api/v1/timelines/public?limit=5" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
params = {
    "limit": "5"
}
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
    "https://mastodon.social/api/v1/timelines/public",
    params=params,
    headers=headers,
)
print(response.json())
const url = new URL('https://mastodon.social/api/v1/timelines/public');
url.searchParams.set('limit', '5');

const response = await fetch(url, {
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	baseURL, _ := url.Parse("https://mastodon.social/api/v1/timelines/public")
	q := baseURL.Query()
	q.Set("limit", "5")
	baseURL.RawQuery = q.Encode()
	targetURL := baseURL.String()
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://mastodon.social/api/v1/timelines/public")
uri.query = URI.encode_www_form({
  "limit" => "5"
})

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://mastodon.social/api/v1/timelines/public?" . http_build_query([
    "limit" => "5"
]);
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "Authorization: Bearer YOUR_ACCESS_TOKEN"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET Search

Search Mastodon for posts and accounts.

https://mastodon.social/api/v1/search?q=open source&limit=5&resolve=false

Hover any highlighted part to learn what it does

curl -X GET "https://mastodon.social/api/v1/search?q=open%20source&limit=5&resolve=false" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
import requests
params = {
    "q": "open source",
    "limit": "5",
    "resolve": "false"
}
headers = {
    "Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
response = requests.get(
    "https://mastodon.social/api/v1/search",
    params=params,
    headers=headers,
)
print(response.json())
const url = new URL('https://mastodon.social/api/v1/search');
url.searchParams.set('q', 'open source');
url.searchParams.set('limit', '5');
url.searchParams.set('resolve', 'false');

const response = await fetch(url, {
  headers: {
    'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
  },
}); 
const data = await response.json();
console.log(data);
package main

import (
	"fmt"
	"io"
	"net/http"
	"net/url"
)

func main() {
	baseURL, _ := url.Parse("https://mastodon.social/api/v1/search")
	q := baseURL.Query()
	q.Set("q", "open source")
	q.Set("limit", "5")
	q.Set("resolve", "false")
	baseURL.RawQuery = q.Encode()
	targetURL := baseURL.String()
	req, _ := http.NewRequest("GET", targetURL, nil)
	req.Header.Set("Authorization", "Bearer YOUR_ACCESS_TOKEN")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()
	body, _ := io.ReadAll(resp.Body)
	fmt.Println(string(body))
}
require "net/http"
require "json"

uri = URI("https://mastodon.social/api/v1/search")
uri.query = URI.encode_www_form({
  "q" => "open source",
  "limit" => "5",
  "resolve" => "false"
})

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"

req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer YOUR_ACCESS_TOKEN"

res = http.request(req)
puts JSON.parse(res.body)
<?php
$url = "https://mastodon.social/api/v1/search?" . http_build_query([
    "q" => "open source",
    "limit" => "5",
    "resolve" => "false"
]);
$opts = ["http" => [
    "method" => "GET",
    "header" => implode("\r\n", [
        "Authorization: Bearer YOUR_ACCESS_TOKEN"
    ]),
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));

Postman Setup Guide

Get Postman ↗
  1. Public timeline requires no auth
  2. GET https://mastodon.social/api/v1/timelines/public?limit=10
  3. For posting: create app at mastodon.social/settings/applications
  4. Set Authorization: Bearer YOUR_ACCESS_TOKEN
  5. Works on any Mastodon instance — replace mastodon.social with your instance

Open documentation ↗