> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.method.security/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.method.security/_mcp/server.

# Using the Method SDK

Method provides a publicly available SDK in python and typescript. This page includes instructions for authenticating
and constructing clients in these languages. The [API Reference](../api-reference) section lists the available
endpoints along with their arguments and responses.

## Python SDK Usage

The Method SDK is published to [pypi](https://pypi.org/project/methodsdk/). Example code to initialize a `MethodClient`
and make a simple API call is:

```python
from method_security import MethodClient

def construct_client_and_get_issue_details(source, issue_id):
    # Replace "my-hostname" with the hostname of your Method instance
    base_url = f"https://my-hostname.method.delivery"
    client = MethodClient(base_url=base_url)

    issue_details = client.v1.issues.get_issue(id=issue_id)
    return issue_details
```

The `get_issue` endpoint used in this example is documented in the [API Reference](../api-reference) section,
which includes all available endpoints, as well as their arguments and responses.

This example assumes that the `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET` environment variables have been set for
authentication, as described in the [Authentication](#authentication) section below.

A small example project using the Method SDK can be found in the
[method-sdk-examples](https://github.com/method-security/method-sdk-examples) repository on github.

## Authentication

The Method SDK uses the OAuth 2.0 Client Credentials flow for authentication. Callers of the SDK are configured with
an OAuth 2.0 client ID and client secret, which are used to acquire access tokens. The SDK acquires access tokens and
uses them to make API calls automatically; callers of the SDK do not need to call authentication endpoints directly.

To configure authentication for an application using the Method SDK:

1. Request the creation of an OAuth 2.0 client for your application from Method Support.
2. Method Support will create this client and provide you with its client ID and client secret.
3. Set environment variables in your application's environment called `OAUTH_CLIENT_ID` and `OAUTH_CLIENT_SECRET`.
   Their values are the client ID and client secret provided in Step 2 respectively. The SDK will detect these variables
   and use them to acquire access tokens automatically.

It is also possible to acquire access tokens manually using the OAuth 2.0 client ID and client secret, and use those
when calling API endpoints. This can be useful for testing, but note that access tokens expire after a short duration,
so production applications should use the flow described above.

## TypeScript SDK Usage

The TypeScript SDK will be published to npm shortly, at which point the documentation will be updated with example usage.