Skip to content

Commit 7890145

Browse files
authored
docs: add ads api docs (#605)
1 parent 1863e4c commit 7890145

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ Learn how to use the full potential of `twitter-api-v2`.
126126
- [Handle errors](./doc/errors.md)
127127
- [Master `twitter-api-v2` paginators](./doc/paginators.md)
128128
- [Discover available helpers](./doc/helpers.md)
129+
- [Twitter Ads API (beta)](./doc/ads.md)
129130

130131
## Plugins
131132

doc/ads.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Twitter Ads API (beta)
2+
3+
The `twitter-api-v2` package includes experimental support for the Twitter Ads API.
4+
5+
> **Beta note:** endpoint-specific helpers are not yet implemented. Use generic HTTP helpers such as `.get`, `.post`, `.put`, etc.
6+
7+
## Authentication & Base URL
8+
9+
The Ads API uses the same OAuth flows as the main client. Create a `TwitterApi` instance with your credentials and access the Ads client through `client.ads`.
10+
11+
The client automatically prefixes requests with the appropriate Ads API base URL, so you don't need to manage the base URL yourself.
12+
13+
```ts
14+
import { TwitterApi } from 'twitter-api-v2';
15+
16+
const client = new TwitterApi({ /* your app credentials */ });
17+
18+
// Access the Ads API
19+
const adsClient = client.ads;
20+
21+
// Access the Ads Sandbox API
22+
const sandbox = client.ads.sandbox;
23+
24+
// Use generic HTTP helpers
25+
const accounts = await adsClient.get('accounts');
26+
```
27+
28+
The sandbox client uses the Ads sandbox base URL internally as well.

doc/v2.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ for await (const mutedUser of mutedPaginator) {
10301030

10311031
**Example**
10321032
```ts
1033-
const mediaId = await client.v2.uploadMedia(Buffer.from('imgae.png'), { media_type: 'image/png' });
1033+
const mediaId = await client.v2.uploadMedia(Buffer.from('image.png'), { media_type: 'image/png' });
10341034
const newTweet = await client.v1.tweet('Hello!', { media_ids: mediaId });
10351035
```
10361036

0 commit comments

Comments
 (0)