> For the complete documentation index, see [llms.txt](https://docs.datafiniti.co/llms.txt).
> Use it to discover all available pages before exploring further.

# People Data

Search millions of people records using the Datafiniti API.



<PlaygroundComponent />

<AuthParams schemes={["BearerAuth"]}>
<AuthType scheme="BearerAuth">
<ParamField header="Authorization" param-type="string" required="true">
Bearer token. Bearer token obtained from the /auth endpoint. Include in requests as: Authorization: Bearer \<token>
</ParamField>
</AuthType>
</AuthParams>

<BodyParams contentTypes={["application/json"]} defaultType="application/json">
  <ContentType type="application/json">
<ParamField showLocation="false" body="query" param-type="string" required="true">
The search query using Datafiniti query syntax (e.g., `keys:*`, `country:US AND province:FL`)
</ParamField>

<ParamField showLocation="false" body="num_records" param-type="integer" required="false">
The number of records your request will return, and the number of credits that will be deducted from your account. For non-downloads, the maximum is 10 records.
</ParamField>

<ParamField showLocation="false" body="format" param-type="string" required="false" enum="json,csv">
Must be either `json` or `csv`. Defaults to `json`.
</ParamField>

<ParamField showLocation="false" body="download" param-type="boolean" required="false">
Whether or not to start a download for this search.
</ParamField>

<ParamField showLocation="false" body="view" param-type="string" required="false">
Specify a view you have created, or use a pre-made view. The view filters what data is displayed in your search results. This allows you to dynamically specify a view to filter the data you get back from your search.
</ParamField>
  </ContentType>
</BodyParams>

<Request tabs="curl,python,javascript,go,ruby">

```bash
curl -X POST "https://api.datafiniti.co/v4/people/search" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -d '{
  "query": "keys:*",
  "num_records": 1
}'
```

```python
import requests
import json

url = "https://api.datafiniti.co/v4/people/search"
headers = {
  "Content-Type": "application/json",
  "Authorization": "Bearer YOUR_API_TOKEN"
}
data = {
  "query": "keys:*",
  "num_records": 1
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
```

```javascript
const response = await fetch("https://api.datafiniti.co/v4/people/search", {
  method: "POST",
  headers: {
  "Content-Type": "application/json",
  "Authorization": "Bearer YOUR_API_TOKEN"
},
  body: JSON.stringify({
  "query": "keys:*",
  "num_records": 1
})
});

const data = await response.json();
console.log(data);
```

```go
package main

import (
    "fmt"
    "net/http"
    "bytes"
    "encoding/json"
)

func main() {
    data := []byte(`{
  "query": "keys:*",
  "num_records": 1
}`)

    req, err := http.NewRequest("POST", "https://api.datafiniti.co/v4/people/search", bytes.NewBuffer(data))
    if err != nil {
        panic(err)
    }

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    fmt.Println("Response Status:", resp.Status)
}
```

```ruby
require 'net/http'
require 'json'

uri = URI('https://api.datafiniti.co/v4/people/search')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = 'Bearer YOUR_API_TOKEN'
request.body = '{
  "query": "keys:*",
  "num_records": 1
}'

response = http.request(request)
puts response.body
```

</Request>

### Responses

<div data-component="ResponsesCollection"><Expandable title="200 - Successful search returning matching people records" default-open="true">

<ResponseField name="num_found" field-type="integer" required="false">
Total number of matching records found
</ResponseField>

<ResponseField name="total_cost" field-type="number" required="false">
Total credit cost for this request
</ResponseField>

<ResponseField name="records" field-type="object[]" required="false">
Array of matching records
</ResponseField>

<ResponseField name="download_id" field-type="string" required="false">
Download ID if download was requested (only present when download: true)
</ResponseField>

</Expandable>

<Expandable title="400 - Invalid query syntax or malformed parameters" default-open="false">

<ResponseField name="error" field-type="string" required="false">
Error message describing what went wrong
</ResponseField>

</Expandable>

</div>

<Response tabs="200,400">

```json
{
  "num_found": 42,
  "total_cost": 3.14,
  "records": [
    {}
  ],
  "download_id": "example_string"
}
```

```json
{
  "error": "Bad Request",
  "message": "The request contains invalid parameters or malformed data",
  "code": 400,
  "details": [
    {
      "field": "email",
      "message": "Invalid email format"
    }
  ]
}
```

</Response>

