NewsTrp API
Build on top of NewsTrp using our open REST API. All responses are in JSON format.
Base URL
https://newstrp.com/api/public/
🔐 Authentication
NewsTrp uses JWT (JSON Web Tokens) for authentication. Include the token in your requests:
Authorization: Bearer YOUR_JWT_TOKEN
POST /auth/register.php
{
"username": "string (3-30 chars)",
"email": "string (valid email)",
"password": "string (min 8 chars)",
"display_name": "string (optional)"
}
// Response 201
{
"status": "success",
"token": "eyJhbGci...",
"user": { "id": 1, "username": "...", ... }
}
POST /auth/login.php
{
"identifier": "email or username",
"password": "string"
}
// Response 200
{
"status": "success",
"token": "eyJhbGci...",
"user": { ... },
"organizations": [ ... ]
}
📰 Feed API
GET /feed.php
| Parameter | Type | Default | Description |
|---|---|---|---|
| tab | string | for_you | for_you | following | trending | latest | local | national | world |
| category | string | — | technology | business | sports | etc. |
| page | int | 1 | Pagination page number |
| limit | int | 15 | Results per page (5-20) |
✍️ Posts API
POST /posts/create.php Auth Required
{
"content_body": "string (required)",
"title": "string (optional)",
"post_type": "short_update | news_article | breaking_news | opinion | thread | ...",
"category": "technology | sports | ...",
"tags": ["tag1","tag2"],
"media_urls": ["https://..."],
"is_breaking": false,
"publisher_type":"user | organization",
"publisher_id": 123
}
GET /posts/get.php?id={postId}
// Response 200
{ "status": "success", "data": { ...post fields + publisher info... } }
POST /posts/like.php Auth
{ "post_id": 123 }
// Response: { "status": "success", "liked": true, "likes_count": 42 }
🔍 Search API
GET /search/global.php
?q=keyword&type=all|people|organizations|posts|topics&page=1
// Response
{
"status": "success",
"query": "ai",
"results": {
"people": [...],
"organizations": [...],
"posts": [...],
"topics": [...]
}
}
⚠️ Rate Limits: Public endpoints: 60 req/min. Authenticated: 300 req/min. Publishing: 30 posts/hr.
🔑 Get Your API Key
For production applications, generate an API key from your settings page for higher rate limits and webhook support.
Generate API Key View Full Docs