Package: archetypesdk
Archetype Python LibraryThe Archetype Python library provides convenient access to the Archetype API from applications written in Python. It includes a pre-defined set of classes for API resources that initialize themselves dynamically from API responses which makes it compatible with a wide range of versions of the Archetype API.The SDK has everything you need to build and manage API subscriptions, usage-based billing, tracking metered usage, issue volume based discounts, graduated pricing models and more.About ArchetypeArchetypeis the revenue infrastruce that make API monetization quick and painless. It works by integrating powerful, reliable purchase server with cross-platform support. Our open-source framework provides a backend and a wrapper around payment processors like Stripe to save engineers months from having to build custom billing infrastructure for their APIs.Whether you are building a new API or already have millions of customers, you can use Archetype to:Fetch products, make purchases, and check subscription status with ournative SDKs.Host addconfigure productsremotely from our dashboard.Analyze the most important metrics for your app businessin one place.See customer transaction histories, chart lifetime value, andgrant promotional subscriptions.Sign up toget started.DocumentationIf looking to use our APIs directly, theAPI referenceis here.With Archetype, you can keep track of all your app transactions in one place — whether your customers are charged through iOS, Android, or the web. As the single source of truth for your API business, we make sure your customers' subscription status is always up to date.InstallationExplore the docs and view the quickstart guideYou don't need this source code unless you want to modify the package. If you just want to use the package, just run:pipinstall--upgradearchetypesdkRequirementsPython 3.6+ (PyPy supported)UsageThe library needs to be configured with your account'sapp_idandsecret keywhich is available in yourArchetype Dashboard. Setarchetype.app_idandarchetype.secret_keyto their values:importarchetypesdkasarchetypearchetype.app_id="ARCHETYPE_APP_ID"archetype.secret_key="ARCHETYPE_SECRET_KEY"CUSTOM_CUSTOMER_UID="XXX"# list customerscustomers=archetype.Customer.All()# print the first customer's emailprint(customers[0]["email"])# retrieve specific Customercustomer=archetype.Customer.Retrieve(CUSTOM_CUSTOMER_UID)# print that customer's emailprint(customer["email"])## Track a Metered Usagearchetype.BillableMetric.LogUsage(custom_uid=CUSTOM_CUSTOMER_UID,billable_metric_id=BILLABLE_METRIC_ID,used_amount=AMOUNT,)# Authorize a Flask Request with Archetype MiddelwarefromflaskimportFlaskapp=Flask(__name__)@app.route("/a",methods=["GET","POST"])@archetype.Authdefauth_test_url():returnjsonify({"response":"success!"}),200# Authorize a Django Request with Archetype Middelware@archetype.Authdefsensitive_fbv(request,*args,**kwargs):returnHttpResponse()# Authorize a FastAPI Request with Archetype Middelwarefromarchetypesdk.fastapiimportauthorized@app.get("/authorize")asyncdefhello_world(is_authorized=Depends(authorized)):return{"response":"Success"}You can leverage the SDK to create and configure billable metrics, products, token management, authorization and more. Check outthe docsfor more examples and use cases.