# Retrieve large number of search results

Returns array of tweets provided by Twitter search page. Although Twitter returns \~20 search results per page, this endpoint will attempt to retrieve more results by sending additional requests until max\_count is reached.

### Endpoint

```url
POST https://api.socialdata.tools/twitter/search/asyncJob
```

### Endpoint parameters

| Name                                        | Description                                                                                                                                                        | Example                                   |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------- |
| <p>query<br><strong>(Required)</strong></p> | A UTF-8, URL-encoded search query , including any operators supported by Twitter website search.                                                                   | from:elon\_musk since\_id:123 max\_id:345 |
| <p>type<br>(optional)</p>                   | <p>Search type (Latest for recent tweets or Top for popular tweets)<br></p><p>Default: Latest</p>                                                                  | Latest                                    |
| <p>since\_id<br>(optional)</p>              | Job will stop execution once this Tweet ID is reached                                                                                                              | 166251761328391335                        |
| <p>max\_id<br>(optional)</p>                | Tweet ID to start scraping from. This will be appended to your search query as `max_id:[ID]`                                                                       | 176251765328391335                        |
| <p>max\_count<br>(optional)</p>             | <p>Maximum number of tweets to be returned. Use this to control your costs<br><br>Default: 20</p>                                                                  | 100                                       |
| <p>compress<br>(optional)</p>               | <p>Indicates whether dataset should be compressed to zip before uploading to S3<br></p><p>Default: false</p>                                                       | false                                     |
| <p>output\_format<br>(optional)</p>         | <p>Preferred output file format. <br><br>Supported values: csv, json, xlsx. <strong>Json recommended</strong> due to more detailed output<br><br>Default: json</p> | json                                      |

### Response codes

* **HTTP 200 OK -** succeeded
* **HTTP 402 Payment Required** - not enough credits to perform this request
* **HTTP 422 Unprocessable Content** - validation failed (e.g. one of the required parameters was not provided)
* **HTTP 500** **Internal Server Error** - other error (highly unlikely)

### Example response

```json
// If succeeded: 
{
    "status": "success",
    "job_id": 42
}
```

### Example job status response

Once a job is processed, the following response will be provided by `GET /jobs/[job_id]` endpoint or by webhook event:

```json
{
    "job_id": 42
    "status": "success",
    "result": {
        "is_compressed": false,
        "datafile_url": "https://s3.amazonaws.com/..."
    }
}
```
