# Connect using Open API
source: https://developer.mastercard.com/straight-through-processing/documentation/tutorials-and-guides/connect-using-open-api-tutorial/index.md

## Overview {#overview}

This tutorial explains how to generate a simple client application from an OpenAPI specification to consume the STP API and walks you through the steps to integrate with Mastercard's OAuth 1.0 authentication and authorization flow.

### You will learn how to {#you-will-learn-how-to}

* Generate a REST client from an OpenAPI or Swagger specification.
* Sign requests using our **OAuth1.0a** signer libraries

## Prerequisites {#prerequisites}

Before starting this tutorial, ensure that the following tasks are completed:

1. Supplier details are provided to the Mastercard implementation team.
2. The project is created, and the required credentials are retrieved as described in the [Create a Sandbox project](https://developer.mastercard.com/straight-through-processing/documentation/tutorials-and-guides/create-sandbox-project-tutorial/index.md) tutorial.
3. The consumer key is shared with the Mastercard implementation team and received.
4. The project is onboarded to the Sandbox environment.

## Download the OpenAPI/Swagger spec file {#download-the-openapiswagger-spec-file}

1. Open the [STP Swagger file](https://developer.mastercard.com/straight-through-processing/documentation/api-reference/index.md).
2. Download the Swagger file in YAML format. (You can download the latest version [here](https://static.developer.mastercard.com/content/straight-through-processing/swagger/stp-api.yaml)).
3. Save the Swagger file and rename it to **STP_API.yaml**.

## Generate the client {#generate-the-client}

Mastercard provides the following generic tutorial on generating an Open API client:

[Generating an Open API client](https://developer.mastercard.com/platform/documentation/security-and-authentication/generating-and-configuring-a-mastercard-api-client/)

Complete steps 3 to 6 from the generic tutorial and return here after completing step 6.

The tutorial uses Java. You can find tutorials for all six supported languages on [Github](https://github.com/Mastercard/mastercard-api-client-tutorial).

For more information on swagger-codegen and other options, see the official page on [Github](https://github.com/OpenAPITools/openapi-generator).

## Call the STP API {#call-the-stp-api}

The following code calls the Get Providers endpoint. If you connect successfully, it prints out a list of providers for your account.

```java
 ApiClient client = new ApiClient();
//Here we set the path to hit the STP sandbox. For production you don't need to do this
client.setBasePath("https://sandbox.api.mastercard.com/stp-api/v1");

//This code shows you how to setup your signing key using the credentials you got when creating your project
PrivateKey signingKey = AuthenticationUtils.loadSigningKey(
        "path to your p12 file here",
        "keyalias",
        "keystorepassword");

//This code shows you how add the interceptor for the oauth1 authentication that Mastercard Developers uses
client.setHttpClient(
        client.getHttpClient()
                .newBuilder()
                .addInterceptor(new OkHttpOAuth1Interceptor("your consumer key here", signingKey))
                .build()
);

//Get Providers example
 ProvidersApi providersApi = new ProvidersApi(client);
Providers providers = providersApi.providersGet();

System.out.println(providers);
```

