Example 1: http Post to the API
This example demonstrates how to post data to the API using a valid API key. The payload includes details about a source and associated quotes.Request
Request:Copy
POST /sources HTTP/1.1
Host: https://api.flybyrd.io/
x-api-key: <yourValidApiKey>
Content-Type: application/json
Copy
{
"title": "Example Reddit Post",
"externalId": "ext-123",
"service": "reddit",
"channelName": "r/example",
"channelId": "subreddit-123",
"createdAt": "2021-01-01T00:00:00.000Z",
"url": "https://reddit.com/r/example/posts/123",
"upVotes": 100,
"downVotes": 10,
"score": 90,
"quotes": [
{
"externalId": "ext-123",
"text": "Reddit post content",
"username": "user123",
"createdAt": "2021-01-01T01:00:00.000Z",
"upVotes": 100,
"downVotes": 10,
"score": 90,
"replyingTo": null
},
{
"externalId": "comment-292",
"text": "First comment",
"username": "user123",
"createdAt": "2021-01-01T18:44:04.000Z",
"upVotes": 14,
"downVotes": 0,
"score": 14,
"replyingTo": "ext-123"
},
{
"externalId": "comment-889",
"text": "Second comment",
"username": "user123",
"createdAt": "2021-01-03:23:56.000Z",
"upVotes": 0,
"downVotes": 0,
"score": 0,
"replyingTo": "ext-123"
},
{
"externalId": "comment-083",
"text": "Third comment",
"username": "user123",
"createdAt": "2021-01-04T13:00:00.000Z",
"upVotes": 1,
"downVotes": 0,
"score": 1,
"replyingTo": "comment-889"
}
]
}
Response
Copy
HTTP/1.1 200 OK
Content-Type: application/json
Copy
{
"message": "New source received successfully.",
"source": {
"title": "Example Reddit Post",
"description": null,
"url": "https://reddit.com/r/example/posts/123",
"externalId": "ext-123"
},
"quotes": [
{
"externalId": "ext-123",
"text": "Reddit post content",
"speaker": "user123",
"upVotes": 100,
"downVotes": 10,
"score": 90
},
{
"externalId": "comment-292",
"text": "First comment",
"speaker": "user123",
"upVotes": 14,
"downVotes": 0,
"score": 14,
"replyingTo": "ext-123"
},
{
"externalId": "comment-889",
"text": "Second comment",
"speaker": "user123",
"upVotes": 0,
"downVotes": 0,
"score": 0,
"replyingTo": "ext-123"
},
{
"externalId": "comment-083",
"text": "Third comment",
"speaker": "user123",
"upVotes": 1,
"downVotes": 0,
"score": 1,
"replyingTo": "comment-889"
}
]
}
Example 2: Node example
This example demonstrates how to post data to the API using a valid API key. The payload includes details about a source and associated quotes.Request and response
Copy
const API_KEY = process.env.FLYBYRD_API_KEY;
let payload = {
"title": "Example Reddit Post",
"externalId": "ext-123",
"service": "reddit",
"channelName": "r/example",
"channelId": "subreddit-123",
"createdAt": "2021-01-01T00:00:00.000Z",
"url": "https://reddit.com/r/example/posts/123",
"upVotes": 100,
"downVotes": 10,
"score": 90,
"quotes": [
{
"externalId": "ext-123",
"text": "Reddit post content",
"username": "user123",
"createdAt": "2021-01-01T01:00:00.000Z",
"upVotes": 100,
"downVotes": 10,
"score": 90,
"replyingTo": null
},
{
"externalId": "comment-292",
"text": "First comment",
"username": "user123",
"createdAt": "2021-01-01T18:44:04.000Z",
"upVotes": 14,
"downVotes": 0,
"score": 14,
"replyingTo": "ext-123"
},
{
"externalId": "comment-889",
"text": "Second comment",
"username": "user123",
"createdAt": "2021-01-03:23:56.000Z",
"upVotes": 0,
"downVotes": 0,
"score": 0,
"replyingTo": "ext-123"
},
{
"externalId": "comment-083",
"text": "Third comment",
"username": "user123",
"createdAt": "2021-01-04T13:00:00.000Z",
"upVotes": 1,
"downVotes": 0,
"score": 1,
"replyingTo": "comment-889"
}
]
};
const response = await fetch("https://api.flybyrd.io/sources", {
method: 'POST',
headers: {
'x-api-key': API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
const responseData = await response.json();
if (
response.ok &&
responseData.message === 'New source received successfully.' &&
) {
console.log('Source successfully received');
}

