Welcome to the official Asaas API Sdk documentation.
This guide will help you get started with integrating and using the Asaas SDK in your project.
You can find the dependency on Sonatype here.
- API version:
3.0.0 - SDK version:
1.0.3
API pública de integração com a plataforma Asaas.
- Setup & Configuration
- Authentication
- Environments
- Setting a Custom Timeout
- Sample Usage
- Services
- Models
- License
This SDK is compatible with the following versions: Java >= 1.8
If you use Maven, place the following within the dependency tag in your pom.xml file:
<dependency>
<groupId>com.asaas</groupId>
<artifactId>api-sdk</artifactId>
<version>1.0.3</version>
</dependency>If you use Gradle, paste the next line inside the dependencies block of your build.gradle file:
implementation group: com.asaas, name: api-sdk, version: 1.0.3If you use JAR files, package the SDK by running the following command:
mvn compile assembly:singleThen, add the JAR file to your project's classpath.
The AsaasSdk API uses API keys as a form of authentication. An API key is a unique identifier used to authenticate a user, developer, or a program that is calling the API.
When you initialize the SDK, you can set the API key as follows:
import com.asaas.apisdk.AsaasSdk;
import com.asaas.apisdk.config.ApiKeyAuthConfig;
import com.asaas.apisdk.config.AsaasSdkConfig;
public class Main {
public static void main(String[] args) {
ApiKeyAuthConfig apiKeyAuthConfig = ApiKeyAuthConfig.builder()
.apiKey("YOUR_API_KEY")
.apiKeyHeader("YOUR_API_KEY_HEADER")
.build();
AsaasSdkConfig config = AsaasSdkConfig.builder().apiKeyAuthConfig(apiKeyAuthConfig).build();
AsaasSdk asaasSdk = new AsaasSdk(config);
}
}If you need to set or update the API key after initializing the SDK, you can use:
asaasSdk.setApiKey('YOUR_API_KEY');
asaasSdk.setApiKeyHeader('YOUR_API_KEY_HEADER');The SDK supports different environments for various stages of development and deployment.
Here are the available environments:
DEFAULT("https://api.asaas.com/"),
PRODUCTION("https://api.asaas.com/"),
SANDBOX("https://api-sandbox.asaas.com/");To configure the SDK to use a specific environment, you can set the base URL as follows:
import com.asaas.apisdk.AsaasSdk;
import com.asaas.apisdk.config.AsaasSdkConfig;
import com.asaas.apisdk.http.Environment;
public class Main {
public static void main(String[] args) {
AsaasSdkConfig config = AsaasSdkConfig.builder().build();
AsaasSdk asaasSdk = new AsaasSdk(config);
asaasSdk.setEnvironment(Environment.DEFAULT);
}
}You can set a custom timeout for the SDK's HTTP requests as follows:
import com.asaas.apisdk.AsaasSdk;
import com.asaas.apisdk.config.AsaasSdkConfig;
public class Main {
public static void main(String[] args) {
AsaasSdkConfig config = AsaasSdkConfig.builder().timeout(10000).build();
AsaasSdk asaasSdk = new AsaasSdk(config);
}
}Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint:
import com.asaas.apisdk.AsaasSdk;
import com.asaas.apisdk.config.ApiKeyAuthConfig;
import com.asaas.apisdk.config.AsaasSdkConfig;
import com.asaas.apisdk.exceptions.ApiError;
import com.asaas.apisdk.models.ListPaymentsParameters;
import com.asaas.apisdk.models.PaymentListRequestBillingType;
import com.asaas.apisdk.models.PaymentListRequestInvoiceStatus;
import com.asaas.apisdk.models.PaymentListRequestPaymentStatus;
import com.asaas.apisdk.models.PaymentListResponseDto;
public class Main {
public static void main(String[] args) {
AsaasSdkConfig config = AsaasSdkConfig.builder()
.apiKeyAuthConfig(ApiKeyAuthConfig.builder().apiKey("YOUR_API_KEY").build())
.build();
AsaasSdk asaasSdk = new AsaasSdk(config);
ListPaymentsParameters requestParameters = ListPaymentsParameters.builder()
.installment("installment")
.offset(8L)
.limit(10L)
.customer("customer")
.customerGroupName("customerGroupName")
.billingType(PaymentListRequestBillingType.UNDEFINED)
.status(PaymentListRequestPaymentStatus.PENDING)
.subscription("subscription")
.externalReference("externalReference")
.paymentDate("paymentDate")
.invoiceStatus(PaymentListRequestInvoiceStatus.SCHEDULED)
.estimatedCreditDate("estimatedCreditDate")
.pixQrCodeId("pixQrCodeId")
.anticipated(false)
.anticipable(true)
.dateCreatedGe("dateCreated[ge]")
.dateCreatedLe("dateCreated[le]")
.paymentDateGe("paymentDate[ge]")
.paymentDateLe("paymentDate[le]")
.estimatedCreditDateGe("estimatedCreditDate[ge]")
.estimatedCreditDateLe("estimatedCreditDate[le]")
.dueDateGe("dueDate[ge]")
.dueDateLe("dueDate[le]")
.user("user")
.build();
try {
PaymentListResponseDto response = asaasSdk.payment.listPayments(requestParameters);
System.out.println(response);
} catch (ApiError e) {
e.printStackTrace();
}
System.exit(0);
}
}The SDK provides various services to interact with the API.
Below is a list of all available services with links to their detailed documentation:
The SDK includes several models that represent the data structures used in API requests and responses. These models help in organizing and managing the data efficiently.
Below is a list of all available models with links to their detailed documentation:
This SDK is licensed under the MIT License.
See the LICENSE file for more details.