# Instagram Location API

> Find Instagram places by name or near a point, get a place's details and its top or recent posts, as JSON. 1 credit per call.

**Find Instagram places by name or near a latitude and longitude**, get a place's name, category, address and contact, and **read its top or recent posts**.

```
GET https://api.handlehaul.com/v1/search/places?q=&lat=&lng=
GET https://api.handlehaul.com/v1/places/{place}
GET https://api.handlehaul.com/v1/places/{place}/posts
```

- `GET /v1/search/places?q=&lat=&lng=`: Find places
- `GET /v1/places/{place}`: A place
- `GET /v1/places/{place}/posts`: Top or recent posts at a place

**Cost:** 1 credit per successful call (free from cache). Failed calls and private accounts are free.

## Parameters

| Parameter | In | Description |
|---|---|---|
| `q` | query | search: a place name. |
| `lat` | query | search: latitude (with lng). |
| `lng` | query | search: longitude. |
| `place` | path | Numeric place id. |
| `sort` | query | posts: `top` (default) or `recent`. |
| `cursor` | query | `pagination.next_cursor` from the previous page. |
| `fresh` | query | `true` skips the cache. |

## Response

```json
{
  "data": [
    {
      "id": "576929642",
      "name": "atelier Café",
      "category": "Coffee shop",
      "address": "10 cedar Street",
      "city": "Paris",
      "lat": 48.85,
      "lng": 2.35,
      "phone": null,
      "website": null
    }
  ],
  "pagination": {
    "next_cursor": null,
    "has_more": false,
    "page_size": 10
  },
  "meta": {
    "request_id": "req_…",
    "cached": false,
    "cache_age_seconds": 0,
    "credits_charged": 1,
    "credits_remaining": 26943
  }
}
```

## Examples

```bash
curl "https://api.handlehaul.com/v1/search/places?lat=48.8584&lng=2.2945" -H "X-Api-Key: $HANDLEHAUL_API_KEY"
```

```python
import os, requests
r = requests.get("https://api.handlehaul.com/v1/search/places?lat=48.8584&lng=2.2945",
                 headers={"X-Api-Key": os.environ["HANDLEHAUL_API_KEY"]}, timeout=30)
r.raise_for_status()
for p in r.json()["data"]:
    print(p["id"], p["name"], p["city"])
```

```javascript
const res = await fetch("https://api.handlehaul.com/v1/search/places?lat=48.8584&lng=2.2945", {
  headers: { "X-Api-Key": process.env.HANDLEHAUL_API_KEY },
});
const { data: places } = await res.json();
```

```php
$ch = curl_init("https://api.handlehaul.com/v1/search/places?lat=48.8584&lng=2.2945");
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => ["X-Api-Key: " . getenv("HANDLEHAUL_API_KEY")],
    CURLOPT_RETURNTRANSFER => true,
]);
$body = json_decode(curl_exec($ch), true);
print_r($body["data"]);
```

```go
req, _ := http.NewRequest("GET", "https://api.handlehaul.com/v1/search/places?lat=48.8584&lng=2.2945", nil)
req.Header.Set("X-Api-Key", os.Getenv("HANDLEHAUL_API_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
    log.Fatal(err)
}
defer res.Body.Close()
var body map[string]any
json.NewDecoder(res.Body).Decode(&body)
fmt.Println(body["data"])
```

## FAQ

### How do I get Instagram posts from a location?
Find the place with `GET /v1/search/places`, then call `GET /v1/places/{id}/posts?sort=recent` for the newest posts tagged there.
