> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/authentication/accessing-via-postman-graphql-schema-examples.md).

# Accessing via Postman / GraphQL Schema examples

## Postman

Once you have generated your Bearer token, you can access the GraphQL schema easily using Postman. Simply take your generated token, and create a new request using the GraphQL feature:

<figure><img src="/files/jSKH3Y0MOHfB5bWRDIrZ" alt=""><figcaption><p>Select GraphQL from the dropdown.</p></figcaption></figure>

<figure><img src="/files/QXlrCDmtFuBFs39iMBrI" alt=""><figcaption><p>Authenticate using your generated Bearer token.</p></figcaption></figure>

Load the GraphQL schema by entering the URL (<https://api.staging.v2.tnid.com/company> for example, for the /company endpoints), and then press "Use GraphQL Introspection" on the Schema tab.

<figure><img src="/files/ss6jSrlzCggc6MD8dUI2" alt=""><figcaption><p>Press "Use GraphQL Introspection" to load the schema.</p></figcaption></figure>

<figure><img src="/files/kBlODgByjjuWRipoFAEO" alt=""><figcaption></figcaption></figure>

The schema should now be accessible via Postman.

## Example Code to access GraphQL Schema

{% tabs %}
{% tab title="Python" %}

```
import aiohttp
import pprint
from gql import gql, Client
from gql.transport.aiohttp import AIOHTTPTransport

# courtesy of https://github.com/PockyBum522/
# Please note that this basic example won't work if you have an asyncio event loop running.
# In some python environments (as with Jupyter which uses IPython) an asyncio event loop is created for you.
# In that case you should use instead https://gql.readthedocs.io/en/latest/async/async_usage.html#async-usage
def get_full_company_endpoint_schema(bearer_token):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/company",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    # Make a valid query so that gql can fetch the full schema
    query = gql(
        """
        query (
            $name: String
            $taxId: String
            $email: String
            $telephoneNumber: String
            $webpage: String
            $limit: Int
          ) {
            companies (
            name: $name
            taxId: $taxId
            email: $email
            telephoneNumber: $telephoneNumber
            webpage: $webpage
            limit: $limit
            ) {
            id
            legalName
            brandName
            profileName
            taxId
            }
          }
        """
    )

    params = { "name": "schema query" }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)

        # Working with the schema GQL gave us from the server
        schema = client.introspection

        print(f"Response OK: {response}")

        # Pretty print out the schema to the console
        print("Schema: ")
        pprint.pp(schema)

        return response
    except Exception as e:
        print(f"Exception: {e}")


def get_full_user_endpoint_schema(bearer_token, query_name = None, tax_id = None, email = None, phone_number = None, webpage = None, limit_count = 10):
    transport = AIOHTTPTransport(
        url="https://api.staging.v2.tnid.com/user",
        headers=
        {
            "Authorization": f"Bearer {bearer_token}"
        }
    )

    # Create a GraphQL client using the defined transport
    client = Client(transport=transport, fetch_schema_from_transport=True)

    # Make a valid query so that gql can fetch the full schema
    query = gql(
        """
        query (
            $channelType: SpamReportChannelType
            $issueType: SpamReportIssueType
            $includedStatus: SpamReportStatus
            $excludedStatus: SpamReportStatus
            $limit: Int
          ) {
            spamReports (
            channelType: $channelType
            issueType: $issueType
            includedStatus: $includedStatus
            excludedStatus: $excludedStatus
            limit: $limit
            ) {
            id
            fromNumber
            toNumber
            userNote
            messageContent
            channelType
            issueType
            status
            createdAt
            updatedAt
            timestamp
            metadata
            user {
                id
            }
            }
          }
        """
    )

    params = { "limit": 1 }

    try:
        # Execute the query on the transport
        response = client.execute(query, params)

        # Working with the schema GQL gave us from the server
        schema = client.introspection

        print(f"Response OK: {response}")

        # Pretty print out the schema to the console
        print("Schema: ")
        pprint.pp(schema)

        return response
    except Exception as e:
        print(f"Exception: {e}")


# Example usage:
token = "your_company_token"
get_full_company_endpoint_schema(token)

# OR
# token = "your_user_token"
# get_full_user_endpoint_schema(token)
```

{% endtab %}

{% tab title="Second Tab" %}

{% endtab %}
{% endtabs %}
