Follow, connect and block

Follow members, communities and tags, send and answer connection requests, block and unblock, and list your network with the Ur Next Door API.

View as Markdown

Scope: network (lists need browse) ยท Quotas: follow and connect, with a tight per-minute limit; accepting, declining, cancelling and unblocking are not counted

Name a member by username (with or without the @) or by user_id, a community or tag by its slug or id.

Follow and unfollow

Set the state you want; a repeat changes nothing and sends no second notification:

cURL
curl -X PUT "https://urnextdoor.com/api/v1/follows" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "user",
  "username": "aarav",
  "following": true
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/follows", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "user",
    username: "aarav",
    following: true,
  }),
});
console.log(res.status, await res.json());
Python
import os

import requests

api_key = os.environ["UND_API_KEY"]

response = requests.put(
    "https://urnextdoor.com/api/v1/follows",
    headers={
        "Authorization": f"Bearer {api_key}",
    },
    json={
        "type": "user",
        "username": "aarav",
        "following": True,
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'type' => 'user',
    'username' => 'aarav',
    'following' => true,
];

$ch = curl_init('https://urnextdoor.com/api/v1/follows');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

echo $status, PHP_EOL, $body, PHP_EOL;

type is user, community or tag. following: false unfollows.

Connections

WhatEndpoint
Send a requestPOST /api/v1/connections/request
Accept a request you receivedPOST /api/v1/connections/accept
Decline itPOST /api/v1/connections/decline
Take back a request you sentPOST /api/v1/connections/cancel
List your connections and requestsGET /api/v1/me/connections?list=accepted (or incoming, outgoing)

Each takes {"username": "asha"} and answers the state between you: none, pending_outgoing, pending_incoming or connected. A request to someone who already asked you connects you at once. Members can choose who may send them requests; a refused request answers 422 with the reason.

cURL
curl -X POST "https://urnextdoor.com/api/v1/connections/request" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "username": "aarav"
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/connections/request", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    username: "aarav",
  }),
});
console.log(res.status, await res.json());
Python
import os
import uuid

import requests

api_key = os.environ["UND_API_KEY"]

response = requests.post(
    "https://urnextdoor.com/api/v1/connections/request",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "username": "aarav",
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'username' => 'aarav',
];

$ch = curl_init('https://urnextdoor.com/api/v1/connections/request');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $apiKey,
        'Content-Type: application/json',
        'Idempotency-Key: ' . bin2hex(random_bytes(16)),
    ],
    CURLOPT_POSTFIELDS => json_encode($payload),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

echo $status, PHP_EOL, $body, PHP_EOL;

Removing a connection stays on the website.

Block and unblock

POST /api/v1/blocks and POST /api/v1/blocks/remove, with {"username": "..."}. A block ends connections and follows between you, and you stop seeing each other's content. Unblocking does not bring them back. GET /api/v1/me/blocked lists everyone you blocked.

What you follow

GET /api/v1/me/following?list=users (or communities, tags). Without list, a first page of each.

Next steps

Last updated