Sample Search Request & Response

Below is a sample URL with the appropriate authorization code and body.

📘

Multi-Lanugage Sample Support

Here at Datastreamer; we will always give out sample codes in different development languages to support the majority of the developers. The API References endpoints have more than 20 programming languages.

curl --location --request POST 'https://api.platform.datastreamer.io/api/search' \
--header 'Content-Type: application/json' \
--header 'apikey: YOUR_API_KEY' \
--data-raw '{
    "query": {
        "size": 1,
        "data_sources": ["wsl_twitter"],
        "query": "Las Vegas",
       
        "sort": [
            {
                "field": "content.published",
                "order": "desc"
            }
        ]
    }
}'
var client = new RestClient("https://api.platform.datastreamer.io/api/search");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("apikey", "YOUR_API_KEY");
var body = @"{" + "\n" +
@"  ""query"": {" + "\n" +
@"    ""from"": 0," + "\n" +
@"    ""size"": 10," + "\n" +
@"    ""query"": ""New York""," + "\n" +
@"    ""data_sources"": [" + "\n" +
@"         ""instagram"",""twitter""" + "\n" +
@"    ]" + "\n" +
@"  }" + "\n" +
@"}";
request.AddParameter("application/json", body,  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var settings = {
  "url": "https://api.platform.datastreamer.io/api/search",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Content-Type": "application/json",
    "apikey": "YOUR_API_KEY"
  },
  "data": JSON.stringify({
    "query": {
      "from": 0,
      "size": 10,
      "query": "New York",
      "data_sources": [
        "instagram",
        "twitter"
      ]
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
#import <Foundation/Foundation.h>

dispatch_semaphore_t sema = dispatch_semaphore_create(0);

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.platform.datastreamer.io/api/search"]
  cachePolicy:NSURLRequestUseProtocolCachePolicy
  timeoutInterval:10.0];
NSDictionary *headers = @{
  @"Content-Type": @"application/json",
  @"apikey": @"YOUR_API_KEY"
};

[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\n  \"query\": {\n    \"from\": 0,\n    \"size\": 10,\n    \"query\": \"New York\",\n    \"data_sources\": [\n         \"instagram\",\"twitter\"\n    ]\n  }\n}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];

[request setHTTPMethod:@"POST"];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
  if (error) {
    NSLog(@"%@", error);
    dispatch_semaphore_signal(sema);
  } else {
    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
    NSError *parseError = nil;
    NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
    NSLog(@"%@",responseDictionary);
    dispatch_semaphore_signal(sema);
  }
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://api.platform.datastreamer.io/api/search',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "query": {
    "from": 0,
    "size": 10,
    "query": "New York",
    "data_sources": [
         "instagram","twitter"
    ]
  }
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'apikey: YOUR_API_KEY'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import http.client
import json

conn = http.client.HTTPSConnection("api.platform.datastreamer.io")
payload = json.dumps({
  "query": {
    "from": 0,
    "size": 10,
    "query": "New York",
    "data_sources": [
      "instagram",
      "twitter"
    ]
  }
})
headers = {
  'Content-Type': 'application/json',
  'apikey': 'YOUR_API_KEY'
}
conn.request("POST", "/api/search", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("apikey", "YOUR_API_KEY")

$body = "{`n  `"query`": {`n    `"from`": 0,`n    `"size`": 10,`n    `"query`": `"New York`",`n    `"data_sources`": [`n         `"instagram`",`"twitter`"`n    ]`n  }`n}"

$response = Invoke-RestMethod 'https://api.platform.datastreamer.io/api/search' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

This request is responded to by a 200 Response Code with the following JSON.

{
    "results": [
        {
            "id": "1646766821028700399-artemis",
            "data_source": "wsl_twitter",
            "source": {
                "link": "https://twitter.com/npnewamericans/status/1501274294852096000"
            },
            "content": {
                "body": "#ICYMI: We celebrated #InternationalWomensDay with @TXOrgProject and the City of San Antonio with an all-women Mariachi band Las Alteñas and remarks from powerful women activists, naturalized citizens and members of the San Antonio City Council! If you missed it, watch below!",
                "found": "2022-03-08T19:13:41Z",
                "published": "2022-03-08T19:10:58Z",
                "hashtags": [
                    "InternationalWomensDay",
                    "ICYMI"
                ],
                "favorites": 3802,
                "followers": 4043,
                "following": 1929,
                "mentions": [
                    "TXOrgProject"
                ]
            },
            "author": {
                "name": "NPNA",
                "bio": "<p>We represent the nation's largest immigrant coalitions. Aim to achieve vibrant, just democracy for all. Immigrants are the soul of our org, inspire our work</p>",
                "location": "",
                "profile_image_source": "https://pbs.twimg.com/profile_images/1501225151668445184/IUKHGkge_normal.jpg",
                "gender": "UNKNOWN",
                "url": "https://twitter.com/npnewamericans",
                "bio_links": [
                    "http://partnershipfornewamericans.org"
                ],
                "handle": "npnewamericans"
            },
            "enrichment": {
                "sentiment": "POSITIVE",
                "language": "en",
                "reported_violence": {
                    "label": "No violence",
                    "confidence": 0.9921875
                },
                "location_inference": {
                    "label": "Las Vegas",
                    "confidence": 0.833333334
                }
            },
            "twitter": {
                "tweet_type": "POST",
                "retweet_type": "REPLY",
                "post_identifier": "1501274294852096000",
                "user_verified": true,
                "user_id": "469708047"
            }
        }
    ],
    "total": {
        "value": 10000,
        "relation": "gte"
    }
}