> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-oauth-2-ios.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

## Getting started with the Posts lookup endpoints

This quick start guide will help you make your first request to the Posts lookup endpoints with a set of specified fields using Postman.

If you would like to see sample code in different languages, please visit our [X API v2 sample code](https://github.com/xdevplatform/Twitter-API-v2-sample-code) GitHub repository.

<Note>
  ### Prerequisites

  To complete this guide, you will need to have a set of [keys and tokens](/resources/fundamentals/authentication) to authenticate your request. You can generate these keys and tokens by following these steps:

  * [Sign up for a developer account](https://developer.x.com/en/portal/petition/essential/basic-info) and receive approval.
  * Create a [Project](/resources/fundamentals/projects) and an associated [developer App](/resources/fundamentals/developer-apps) in the developer portal.
  * Navigate to your App's “Keys and tokens” page to generate the required credentials. Make sure to save all credentials in a secure location.
</Note>

### Steps to build a GET /tweets request

#### Step one: Start with a tool or library

There are several different tools, code examples, and libraries that you can use to make a request to this endpoint, but we are going to use the Postman tool here to simplify the process.

To load the X API v2 Postman collection into your environment, click the button below:

<Button href="https://app.getpostman.com/run-collection/9956214-784efcda-ed4c-4491-a4c0-a26470a67400">
  Add X API v2 to Postman
</Button>

Once you have the X API v2 collection loaded in Postman, navigate to the "Post Lookup > Multiple Posts" request.

#### Step two: Authenticate your request

To properly make a request to the X API, you need to verify that you have permission. You can authenticate your request with:

* [OAuth 2.0 App-Only](resources/fundamentals/authentication)
* [OAuth 2.0 Authorization Code with PKCE](resources/fundamentals/authentication)
* [OAuth 1.0a User Context](resources/fundamentals/authentication)

For simplicity's sake, we are going to utilize OAuth 2.0 App-Only with this request, but if you'd like to request private [metrics](/x-api/fundamentals/metrics) or Posts, you will need to use one of the other authentication methods.

To utilize OAuth 2.0 App-Only, you must add your keys and tokens (and specifically the App Access Token, also known as the App-only Bearer Token) to Postman by selecting the environment named “X API v2” (in the top-right corner of Postman), and adding your keys and tokens to the "initial value" and "current value" fields (by clicking the eye icon next to the environment dropdown).

If you've done this correctly, these variables will automatically be pulled into the request's authorization tab.

#### Step three: Identify and specify which Posts you would like to retrieve

You must specify a Post or a set of Posts that you would like to receive within the request. You can find the Post ID by navigating to X.com and clicking on a Post and then looking in the URL. For example, the following URL's Post ID is `1228393702244134912`.

`https://x.com/TwitterDev/status/1228393702244134912`

In Postman, navigate to the "Params" tab and enter this ID, or a string of Post IDs separated by a comma, into the "Value" column of the ids parameter.

| Key   | Value                                                         |
| :---- | :------------------------------------------------------------ |
| `ids` | `1228393702244134912,1227640996038684673,1199786642791452673` |

***

#### Step four: Identify and specify which fields you would like to retrieve

If you click the "Send" button after step three, you will receive the default [Post object fields](/x-api/fundamentals/data-dictionary) in your response: `id`, `text`, and `edit_history_tweet_ids`.

For this exercise, we will request a three additional different sets of fields from different objects:

* The additional `tweet.created_at field` in the primary user objects.
* The associated authors’ user object’s default fields for the returned Posts: `id`, `name`, and `username`
* The additional  `user.created_at field` in the associated user objects.

In Postman, navigate to the "Params" tab and add the following `key:value` pair to the "Query Params" table:

| Key            | Value        | Returned fields                                                       |
| :------------- | :----------- | :-------------------------------------------------------------------- |
| `tweet.fields` | `created_at` | `tweets.created_at`                                                   |
| `expansions`   | `author_id`  | `includes.users.id`, `includes.users.name`, `includes.users.username` |
| `user.fields`  | `created_at` | `includes.users.created_at`                                           |

You should see this URL next to the "Send" button:

```
https://api.x.com/2/tweets?ids=1228393702244134912,1227640996038684673,1199786642791452673&tweet.fields=created_at&expansions=author_id&user.fields=created_at
```

#### Step five: Make your request and review your response

Once you have everything set up, hit the "Send" button and you will receive the following response:

```
{
    "data": [
        {
            "edit_history_tweet_ids": [
                "1228393702244134912"
            ],
            "text": "What did the developer write in their Valentine’s card?\n  \nwhile(true) {\n    I = Love(You);  \n}",
            "id": "1228393702244134912",
            "created_at": "2020-02-14T19:00:55.000Z",
            "author_id": "2244994945"
        },
        {
            "edit_history_tweet_ids": [
                "1227640996038684673"
            ],
            "text": "Doctors: Googling stuff online does not make you a doctor\n\nDevelopers: https://t.co/mrju5ypPkb",
            "id": "1227640996038684673",
            "created_at": "2020-02-12T17:09:56.000Z",
            "author_id": "2244994945"
        },
        {
            "edit_history_tweet_ids": [
                "1199786642791452673"
            ],
            "text": "C#",
            "id": "1199786642791452673",
            "created_at": "2019-11-27T20:26:41.000Z",
            "author_id": "2244994945"
        }
    ],
    "includes": {
        "users": [
            {
                "name": "Developers",
                "created_at": "2013-12-14T04:35:55.000Z",
                "id": "2244994945",
                "username": "XDevelopers"
            }
        ]
    }
}
```
