Package: paddle-billing-python-sdk
paddle-billing-python-sdkA Python wrapper for the new Paddle Billing SDK, based on Paddle's officialpaddle-php-sdkCore developersInvincibearTable of contentsRequirementsInstallUsageExamplesResourcesRequirementsPython>=3.11 (for native type hinting, StrEnum, trailing commas, f-strings)Project dependencies(automatically installed by pip):requests>=2.31urllib3>=2.1.0InstallBecausepaddle-billing-python-sdkisavailable on PyPi, installation is as simple as running the followingpipcommand:pip install paddle-billing-python-sdkUsageTo authenticate, you'll need an API key. You can create and manage API keys inPaddle > Developer tools > Authentication.Pass your API key while initializing a new Paddle client:frompaddle_billingimportClientpaddle=Client('PADDLE_API_SECRET_KEY')You can pass your Paddle API secret key into the SDK from an environment variable:fromosimportgetenvfrompaddle_billingimportClientpaddle=Client(getenv('PADDLE_API_SECRET_KEY'))You can also pass an environment to work with Paddle's sandbox:frompaddle_billingimportClient,Environment,Optionspaddle=Client('PADDLE_API_SECRET_KEY',options=Options(Environment.SANDBOX))Keep in mind that API keys are separate for your sandbox and live accounts, so you'll need to generate keys for each environment.ExamplesThere are examples included in theexamples folder. To prevent leaking errors we recommend encapsulating Paddle operations inside Try/Except blocks. For brevity, most of the examples below do not do this.List entitiesYou can list supported entities with thelist()method in the resource. It returns an iterator to help when working with multiple pages.frompaddle_billingimportClientpaddle=Client('PADDLE_API_SECRET_KEY')products=paddle.products.list()# List() returns an iterable, so pagination is automatically handledforproductinproducts:print(f"Product's id:{product.id}")Get an entityYou can get an entity with theget()method in the resource. It accepts theidof the entity to get. The entity is returned.frompaddle_billingimportClientpaddle=Client('PADDLE_API_SECRET_KEY')product=paddle.products.get('PRODUCT_ID')Create an entityYou can create a supported entity with thecreate()method in the resource. It accepts the resource's correspondingCreateOperatione.g.CreateProduct. The created entity is returned.frompaddle_billingimportClientfrompaddle_billing.Entities.Shared.TaxCategoryimportTaxCategoryfrompaddle_billing.Resources.Products.OperationsimportCreateProductpaddle=Client('PADDLE_API_SECRET_KEY')created_product=paddle.products.create(CreateProduct(name='My Product',tax_category=TaxCategory.Standard,))Update an entityYou can update a supported entity with theupdate()method in the resource. It accepts theidof the entity to update and the correspondingUpdateOperatione.g.UpdateProduct. The updated entity is returned.frompaddle_billingimportClientfrompaddle_billing.Resources.Products.OperationsimportUpdateProductpaddle=Client('PADDLE_API_SECRET_KEY')# Update the name of the productupdated_product=paddle.products.update('PRODUCT_ID',UpdateProduct(name='My Improved Product'))Where operations require more than oneid, theupdate()method accepts multiple arguments. For example, to update an address for a customer, pass thecustomerIdand theaddressId:updated_address=paddle.addresses.update('CUSTOMER_ID','ADDRESS_ID',operation_goes_here,)Delete an entityYou can delete an entity with thedelete()method in the resource. It accepts theidof the entity to delete. The deleted entity is returned.frompaddle_billingimportClientpaddle=Client('PADDLE_API_SECRET_KEY')deleted_product=paddle.products.delete('PRODUCT_ID')ResourcesWebhook signature verificationThe SDK includes a helper class to verify webhook signatures sent by Notifications from Paddle.frompaddle_billing.NotificationsimportSecret,Verifierintegrity_check=Verifier().verify(request,Secret('WEBHOOK_SECRET_KEY')Learn morePaddle API referenceSign up for Paddle Billing