Skip to main content

picket-python

The official Python library for the Picket API

Installation

pip install -U picketapi

Usage - Quick Start

Use the Picket class to create the Picket API client. It takes a secret API key as a parameter.

from picketapi import Picket

picket = new Picket("YOU_SECRET_API_KEY")

Nonce

A nonce is random value generated by the Picket API to that user must sign to prove ownership a wallet address. The nonce function can be used to implement your own wallet authentication flow.

A nonce is unique to a project and wallet address. If a nonce doesn't exist for the project and wallet address, Picket will generate a new nonce; otherwise, Picket will return the existing nonce. A nonce is valid for two minutes before self-destructing.

resp = picket.nonce(chain="solana", wallet_address="wAlLetTAdDress")
# resp is of type NonceResponse
print(resp.nonce)

Auth

auth is the server-side equivalent of login. auth should only be used in a trusted server environment. The most common use-case for auth is linking a wallet to an existing application account.

resp = picket.auth(chain="ethereum", wallet_address="0x1234567890", signature="abcdefghijklmnop")
# resp is of type AuthResponse
print(resp.user)
print(resp.access_token)

Authz (Authorize)

authz stands for authorization. Unlike Auth, which handles both authentication and authorization, Authz only handles authorization. Given an authenticated user's access token and authorization requirements, authz will issue a new access token on success (user is authorized) or, on failure, it will return a 4xx HTTP error code.

resp = picket.authz(access_token="xxx.yyy.zzz", requirements={ "contractAddress": "0xContract" })
# resp is of type AuthResponse
print(resp.user)
print(resp.access_token)

Validate

validate validates an access token. validate should be called, or manually access token validation should be done, server-side before trusting a request's access token. It's common to move access token validation and decoding logic to a shared middleware across API endpoints. If the access token is valid, validate returns the decoded claims of the access token.

resp, err := picket.validate(access_token="xxx.yyy.zzz", requirements={"contractAddress": "0xContract", "minTokenBalance": "100"})
# Response is the decoded access token (AuthorizedUser)
print(resp)

Verify Token Ownership

If you only want to verify token ownership server side for a given wallet, tokenOwnership allows you to do just that.

resp = picket.token_ownership(
			chain="solana", 
			wallet_address="waLLETaddRess", 
			requirements={  
			  "collection": "METAPLEX_COLLECTION",
			  "minTokenBalance": "3",
			}
		)
# Response is of type TokenOwnershipResponse
print(resp.allowed)
print(resp.tokenBalances)

Metadata

Release files for picketapi 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for picketapi 0.1.1
File Size Uploaded Provenance Actions
picketapi-0.1.1.tar.gz 4.2 kB Without provenance Details for picketapi-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for picketapi 0.1.1
File Interpreter ABI Platform Actions
picketapi-0.1.1-py3-none-any.whl Python 3 none any Details for picketapi-0.1.1-py3-none-any.whl

Total release size: 8.9 kB

Release files / picketapi-0.1.1.tar.gz

Download URL picketapi-0.1.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1e25db25931249e0842729c3515649ade0277cab6da4e7f90238c604d72ae2d2
BLAKE2b-256 checksum
How to use checksums
de9ac174114e48c098b981b58715dc026554db342269e3081dbb1c814bb0531b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

Release files / picketapi-0.1.1-py3-none-any.whl

Download URL picketapi-0.1.1-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cabf07a2ba72524c72e160b77f234f096afef6c2e7f96b2049d052db965fd822
BLAKE2b-256 checksum
How to use checksums
696768835fd44d26d4e025f4192e4fd8d0de6c5edff2a75eac8a2067125f2b28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.10.8 Linux/5.15.0-1022-azure

Security for picketapi 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page