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

# एकीकरण मार्गदर्शिका

> DM lookup endpoint के एकीकरण के लिए मुख्य अवधारणाएँ और सर्वोत्तम प्रथाएँ

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>;
};

यह मार्गदर्शिका उन मुख्य अवधारणाओं को समझाती है जिनकी आपको डायरेक्ट मैसेज lookup endpoints को अपने ऐप में एकीकृत करने के लिए आवश्यकता होगी।

***

<div id="authentication">
  ## प्रमाणीकरण
</div>

निजी बातचीतों तक पहुँचने के लिए DM एंडपॉइंट्स पर उपयोगकर्ता प्रमाणीकरण आवश्यक है:

| Method                                                                                                                              | Description   |
| :---------------------------------------------------------------------------------------------------------------------------------- | :------------ |
| [PKCE के साथ OAuth 2.0 Authorization Code](/hi/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2) | अनुशंसित      |
| [OAuth 1.0a User Context](/hi/resources/fundamentals/authentication)                                                                | लीगेसी समर्थन |

<Warning>
  सिर्फ़ ऐप-आधारित प्रमाणीकरण समर्थित नहीं है। सभी डायरेक्ट मैसेज निजी होते हैं।
</Warning>

<div id="required-scopes-oauth-20">
  ### आवश्यक scopes (OAuth 2.0)
</div>

| Scope        | इसके लिए आवश्यक       |
| :----------- | :-------------------- |
| `dm.read`    | इवेंट पढ़ने के लिए    |
| `tweet.read` | dm.read के साथ आवश्यक |
| `users.read` | dm.read के साथ आवश्यक |

***

<div id="conversation-types">
  ## वार्तालाप के प्रकार
</div>

<CardGroup cols={2}>
  <Card title="एक-से-एक" icon="message">
    इसमें हमेशा ठीक दो प्रतिभागी होते हैं। वार्तालाप ID का प्रारूप: `{smaller_user_id}-{larger_user_id}`
  </Card>

  <Card title="समूह" icon="comments">
    इसमें दो या अधिक प्रतिभागी होते हैं। सदस्यता समय के साथ बदल सकती है।
  </Card>
</CardGroup>

***

<div id="event-types">
  ## इवेंट के प्रकार
</div>

| इवेंट               | विवरण                            | मुख्य फ़ील्ड्स                 |
| :------------------ | :------------------------------- | :----------------------------- |
| `MessageCreate`     | एक संदेश भेजा गया                | `text`, `sender_id`            |
| `ParticipantsJoin`  | उपयोगकर्ता समूह में शामिल हुआ    | `participant_ids`, `sender_id` |
| `ParticipantsLeave` | उपयोगकर्ता समूह से बाहर निकल गया | `participant_ids`              |

<div id="example-events">
  ### उदाहरण इवेंट
</div>

<AccordionGroup>
  <Accordion title="MessageCreate">
    ```json theme={null}
    {
      "id": "1582838499983564806",
      "event_type": "MessageCreate",
      "text": "Hi everyone.",
      "sender_id": "944480690",
      "dm_conversation_id": "1578398451921985538",
      "created_at": "2022-10-19T20:58:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="ParticipantsJoin">
    ```json theme={null}
    {
      "id": "1582835469712138240",
      "event_type": "ParticipantsJoin",
      "participant_ids": ["944480690"],
      "sender_id": "17200003",
      "dm_conversation_id": "1578398451921985538",
      "created_at": "2022-10-19T20:45:58.000Z"
    }
    ```
  </Accordion>

  <Accordion title="ParticipantsLeave">
    ```json theme={null}
    {
      "id": "1582838535115067392",
      "event_type": "ParticipantsLeave",
      "participant_ids": ["944480690"],
      "dm_conversation_id": "1578398451921985538",
      "created_at": "2022-10-19T20:58:09.000Z"
    }
    ```
  </Accordion>
</AccordionGroup>

***

<div id="fields-and-expansions">
  ## फ़ील्ड्स और expansions
</div>

<div id="default-fields">
  ### डिफ़ॉल्ट फ़ील्ड्स
</div>

| इवेंट प्रकार           | डिफ़ॉल्ट फ़ील्ड्स                     |
| :--------------------- | :------------------------------------ |
| MessageCreate          | `id`, `event_type`, `text`            |
| ParticipantsJoin/Leave | `id`, `event_type`, `participant_ids` |

<div id="available-fields">
  ### उपलब्ध फ़ील्ड्स
</div>

| फ़ील्ड               | विवरण                    | इवेंट्स             |
| :------------------- | :----------------------- | :------------------ |
| `dm_conversation_id` | वार्तालाप ID             | सभी                 |
| `created_at`         | इवेंट का टाइमस्टैम्प     | सभी                 |
| `sender_id`          | किसने भेजा/आमंत्रित किया | MessageCreate, Join |
| `attachments`        | मीडिया संलग्नक           | MessageCreate       |
| `referenced_tweets`  | साझा की गई पोस्ट्स       | MessageCreate       |

<div id="available-expansions">
  ### उपलब्ध expansions
</div>

| Expansion                | लौटाए गए ऑब्जेक्ट             |
| :----------------------- | :---------------------------- |
| `sender_id`              | प्रेषक का User ऑब्जेक्ट       |
| `participant_ids`        | प्रतिभागियों के User ऑब्जेक्ट |
| `attachments.media_keys` | Media ऑब्जेक्ट                |
| `referenced_tweets.id`   | पोस्ट ऑब्जेक्ट                |

<div id="example-with-expansions">
  ### expansions के साथ उदाहरण
</div>

<CodeGroup dropdown>
  ```bash cURL theme={null}
  curl "https://api.x.com/2/dm_events?\
  dm_event.fields=created_at,sender_id,attachments&\
  expansions=sender_id,attachments.media_keys&\
  user.fields=username,profile_image_url&\
  media.fields=url,type" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

  # expansions के साथ DM इवेंट प्राप्त करें
  for page in client.dm_events.list(
      dm_event_fields=["created_at", "sender_id", "attachments"],
      expansions=["sender_id", "attachments.media_keys"],
      user_fields=["username", "profile_image_url"],
      media_fields=["url", "type"],
      max_results=100
  ):
      for event in page.data:
          print(f"Event: {event.event_type} - {event.text}")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

  const paginator = client.dmEvents.list({
    dmEventFields: ["created_at", "sender_id", "attachments"],
    expansions: ["sender_id", "attachments.media_keys"],
    userFields: ["username", "profile_image_url"],
    mediaFields: ["url", "type"],
    maxResults: 100,
  });

  for await (const page of paginator) {
    page.data?.forEach((event) => {
      console.log(`Event: ${event.event_type} - ${event.text}`);
    });
  }
  ```
</CodeGroup>

***

<div id="pagination">
  ## पेजिनेशन
</div>

DM इवेंट उल्टे कालानुक्रमिक क्रम में लौटाए जाते हैं (सबसे नए पहले):

<CodeGroup dropdown>
  ```bash cURL theme={null}
  # पहला अनुरोध
  curl "https://api.x.com/2/dm_events?max_results=100" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"

  # पेजिनेशन टोकन के साथ अगला अनुरोध
  curl "https://api.x.com/2/dm_events?max_results=100&pagination_token=NEXT_TOKEN" \
    -H "Authorization: Bearer $USER_ACCESS_TOKEN"
  ```

  ```python Python SDK theme={null}
  from xdk import Client

  client = Client(bearer_token="YOUR_USER_ACCESS_TOKEN")

  # SDK पेजिनेशन को अपने-आप संभालता है
  all_events = []

  for page in client.dm_events.list(max_results=100):
      if page.data:
          all_events.extend(page.data)

  print(f"Found {len(all_events)} DM events")
  ```

  ```javascript JavaScript SDK theme={null}
  import { Client } from "@xdevplatform/xdk";

  const client = new Client({ accessToken: "YOUR_USER_ACCESS_TOKEN" });

  async function getAllDMEvents() {
    const allEvents = [];

    // SDK पेजिनेशन को अपने-आप संभालता है
    const paginator = client.dmEvents.list({ maxResults: 100 });

    for await (const page of paginator) {
      if (page.data) {
        allEvents.push(...page.data);
      }
    }

    return allEvents;
  }

  // उपयोग
  const events = await getAllDMEvents();
  console.log(`Found ${events.length} DM events`);
  ```
</CodeGroup>

<Note>
  **30 दिन पहले तक** के इवेंट उपलब्ध हैं।
</Note>

***

<div id="id-compatibility-with-v11">
  ## v1.1 के साथ ID की संगतता
</div>

वार्तालाप और इवेंट ID, v1.1 और v2 endpoint के बीच साझा किए जाते हैं। इसका मतलब है कि आप यह कर सकते हैं:

* इवेंट प्राप्त करने के लिए v2 का उपयोग करें, फिर विशिष्ट संदेशों को हटाने के लिए v1.1 का उपयोग करें
* API अनुरोधों में x.com URL से वार्तालाप ID का संदर्भ दें

***

<div id="next-steps">
  ## अगले चरण
</div>

<CardGroup cols={2}>
  <Card title="त्वरित शुरुआत" icon="rocket" href="/hi/x-api/direct-messages/lookup/quickstart">
    अपना पहला DM lookup अनुरोध भेजें
  </Card>

  <Card title="DMs भेजें" icon="paper-plane" href="/hi/x-api/direct-messages/manage/introduction">
    डायरेक्ट मैसेज भेजें
  </Card>

  <Card title="API संदर्भ" icon="code" href="/hi/x-api/direct-messages/get-dm-events">
    एंडपॉइंट का पूरा दस्तावेज़
  </Card>

  <Card title="नमूना कोड" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    काम करने वाले कोड के उदाहरण
  </Card>
</CardGroup>
