Lanyard API

⭐ Beginner's Pick Social / No Auth Required Beginner HTTPS CORS
Free to Use Varies (check documentation)

Overview

Lanyard is a free, open-source API that exposes your real-time Discord presence such as what you are playing or listening to via a simple REST API or WebSocket. No API key is required — you just need to join the Lanyard Discord server and the API automatically tracks your status. It is a popular choice for adding live Discord status to personal portfolio websites.

💡

Beginner Tip

To use Lanyard, join the official Lanyard Discord server at discord.gg/lanyard and your Discord presence will automatically be tracked. Then fetch your status by replacing the user ID in the URL with your own Discord user ID.

Available Data

Lanyard data via REST API
JSON-formatted response data
Freely accessible without authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Lanyard",
    "description": "Retrieve your presence on Discord through an HTTP REST API or WebSocket",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

data.discord_status User current Discord status: online, idle, dnd (do not disturb), or offline
data.discord_user.username The Discord username of the tracked user
data.activities List of current activities including games, Spotify, and custom statuses
data.listening_to_spotify True if the user is currently listening to Spotify
data.spotify Current Spotify track details including song, artist, album, and album art URL
data.active_on_discord_desktop True if the user is currently active on a desktop Discord client

Implementation Example

const url = "https://github.com/Phineas/lanyard";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

404 User not found The Discord user ID is not being monitored by Lanyard
Join the Lanyard Discord server at discord.gg/lanyard — only members of this server have their presence tracked
Presence shows as offline even when online Discord privacy settings are blocking activity visibility
In Discord Settings under Privacy and Safety, ensure Share your activity status and Display current activity as status message are enabled
WebSocket connection dropping Missing heartbeat — the Lanyard WebSocket requires a heartbeat every 30 seconds
After connecting, send a JSON heartbeat message {"op": 3} every 30 seconds to keep the connection alive

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 20/20
🔒 Security 15/15
🛠 Developer XP 20/20
✓ Reliability 7/15
Response Time 56ms

Fully tested on Apr 5, 2026

Technical Specifications

Auth No Auth
HTTPS REQUIRED
CORS YES
Category Social
Difficulty Beginner
Verified: 2026-04-04

Similar APIs

View All →