Comment, react, save and vote

Take part as yourself through the API: comment and reply, answer questions, like or dislike, save, vote in polls, answer MCQs and report content.

View as Markdown

Everything here acts as you, toward other members: their post gets your comment, they get a notification. Give a key the engage scope only for a tool you trust to speak for you, and tell it to show you each comment before it sends it.

Scope: engage ยท Quotas: comment, answer, react and report, with a tight per-minute limit on each

Comment, reply and answer

WhatEndpointBody
Comment on a postPOST /api/v1/posts/{id}/comments{"body": "..."}
Comment on a poll or an MCQPOST /api/v1/polls/{id}/comments, POST /api/v1/mcqs/{id}/comments{"body": "..."}
Reply to a commentPOST /api/v1/comments/{id}/replies{"body": "..."} (one level deep)
Answer a questionPOST /api/v1/questions/{id}/answers{"body": "<p>HTML</p>"}
cURL
curl -X POST "https://urnextdoor.com/api/v1/posts/41/comments" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "body": "Great tips, thank you!"
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/posts/41/comments", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    body: "Great tips, thank you!",
  }),
});
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/posts/41/comments",
    headers={
        "Authorization": f"Bearer {api_key}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "body": "Great tips, thank you!",
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'body' => 'Great tips, thank you!',
];

$ch = curl_init('https://urnextdoor.com/api/v1/posts/41/comments');
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;

@username in a comment or answer notifies that member. In a community, answering needs the same role as posting there.

Like, dislike, save: set, never toggle

On the website, tapping like twice takes the like back. Through the API you say the state you want, and a repeat changes nothing:

cURL
curl -X PUT "https://urnextdoor.com/api/v1/reactions" \
  -H "Authorization: Bearer $UND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "type": "post",
  "id": 41,
  "reaction": 1
}'
JavaScript
const res = await fetch("https://urnextdoor.com/api/v1/reactions", {
  method: "PUT",
  headers: {
    Authorization: `Bearer ${process.env.UND_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "post",
    id: 41,
    reaction: 1,
  }),
});
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/reactions",
    headers={
        "Authorization": f"Bearer {api_key}",
    },
    json={
        "type": "post",
        "id": 41,
        "reaction": 1,
    },
    timeout=30,
)
print(response.status_code, response.json())
PHP
<?php
$apiKey = getenv('UND_API_KEY');

$payload = [
    'type' => 'post',
    'id' => 41,
    'reaction' => 1,
];

$ch = curl_init('https://urnextdoor.com/api/v1/reactions');
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;
WhatEndpointBody
Like, dislike or clearPUT /api/v1/reactions{"type", "id", "reaction": 1} for like, -1 dislike, 0 none
Save or unsavePUT /api/v1/favorites{"type", "id", "saved": true}

The answer says changed: false when it was already that way. Types: post, question, answer, comment, poll, mcq, service (and job for saves).

Vote and answer

  • Poll: POST /api/v1/polls/{id}/vote with {"option_id": 301}. Voting for another option switches your vote; voting for the same one again keeps it; {"option_id": null} takes your vote back.
  • MCQ: POST /api/v1/mcqs/{id}/answer with {"option_id": 402}. Once only: a second answer is 409. The answer says whether you were right.

Report

POST /api/v1/reports with the type (user, post, question, answer, poll, mcq, comment or job), the id, a reason (spam, harassment, hate, misinfo, nudity, violence or other) and optional details.

What you cannot reach

What you could not open on the website, you cannot act on here either: a post by a member who blocked you, or that you blocked, an item in a private community you are not in, an archived or scheduled item that is not yours. Those answer 404, as if they did not exist.

Next steps

Last updated