Package: pixelbin
Pixelbin Backend SDK for PythonPixelbin Backend SDK for python helps you integrate the core Pixelbin features with your application.Getting StartedGetting started with Pixelbin Backend SDK for PythonInstallationpip install pixelbinUsageQuick ExampleimportasynciofrompixelbinimportPixelbinClient,PixelbinConfig# create client with your API_TOKENconfig=PixelbinConfig({"domain":"https://api.pixelbin.io","apiSecret":"API_TOKEN",})# Create a pixelbin instancepixelbin:PixelbinClient=PixelbinClient(config=config)# Sync method calltry:result=pixelbin.assets.listFiles()print(result)exceptExceptionase:print(e)# Async method calltry:result=asyncio.get_event_loop().run_until_complete(pixelbin.assets.listFilesAsync())print(result)exceptExceptionase:print(e)Security UtilsFor generating Signed URLsGenerate a signed PixelBin urlParameterDescriptionExampleurl(string)A valid Pixelbin URL to be signedhttps://cdn.pixelbin.io/v2/dummy-cloudname/original/__playground/playground-default.jpegexpiry_seconds(int)Number of seconds the signed URL should be valid for20token_id(int or string)ID of the token used for signing42token(string)Value of the token used for signingdummy-tokenExample:frompixelbin.utils.securityimportsign_urlsigned_url=sign_url("https://cdn.pixelbin.io/v2/dummy-cloudname/original/__playground/playground-default.jpeg",# url20,# expiry_seconds42,# token_id"dummy-token",# token);# signed_url# https://cdn.pixelbin.io/v2/dummy-cloudname/original/__playground/playground-default.jpeg?pbs=8eb6a00af74e57967a42316e4de238aa88d92961649764fad1832c1bff101f25&pbe=1695635915&pbt=1Usage with custom domain urlfrompixelbin.utils.securityimportsign_urlsigned_url=sign_url("https://test.example.com/v2/original/__playground/playground-default.jpeg",# url30,# expirySeconds22,# tokenId"dummy-token",# token);# signedUrl# https://test.example.com/v2/original/__playground/playground-default.jpeg?pbs=1aef31c1e0ecd8a875b1d3184f324327f4ab4bce419d81d1eb1a818ee5f2e3eb&pbe=1695705975&pbt=22URL UtilsPixelbin provides url utilities to construct and deconstruct Pixelbin urls.url_to_objDeconstruct a pixelbin urlparameterdescriptionexampleurl(string)A valid Pixelbin URLhttps://cdn.pixelbin.io/v2/your-cloud-name/z-slug/t.resize(h:100,w:200)~t.flip()/path/to/image.jpegopts(Object)Options for the conversionDefault:{ isCustomDomain: False }opts.is_custom_domainIndicates if the URL belongs to a custom domain (default:False)Returns:PropertyDescriptionExamplebaseURL(string)Base path of the URLhttps://cdn.pixelbin.iofilePath(string)Path to the file on Pixelbin storage/path/to/image.jpegversion(string)Version of the URLv2cloudName(string)Cloud name from the URLyour-cloud-nametransformations(array)A list of transformation objects[{ "plugin": "t", "name": "flip" }]zone(string)Zone slug from the URLz-slugpattern(string)Transformation pattern extracted from the URLt.resize(h:100,w:200)~t.flip()worker(boolean)Indicates if the URL is a URL Translation Worker URLFalseworkerPath(string)Input path to a URL Translation Workerresize:w200,h400/folder/image.jpegoptions(Object)Query parameters added, such as "dpr" and "f_auto"{ dpr: 2.5, f_auto: True}Example:frompixelbin.utils.urlimporturl_to_objpixelbinUrl="https://cdn.pixelbin.io/v2/your-cloud-name/z-slug/t.resize(h:100,w:200)~t.flip()/path/to/image.jpeg?dpr=2.0&f_auto=true"obj=url_to_obj(pixelbinUrl)# obj# {#     "cloudName": "your-cloud-name",#     "zone": "z-slug",#     "version": "v2",#     "options": {#         "dpr": 2.0,#         "f_auto": True,#     },#     "transformations": [#         {#             "plugin": "t",#             "name": "resize",#             "values": [#                 {#                     "key": "h",#                     "value": "100"#                 },#                 {#                     "key": "w",#                     "value": "200"#                 }#             ]#         },#         {#             "plugin": "t",#             "name": "flip",#         }#     ],#     "filePath": "path/to/image.jpeg",#     "baseUrl": "https://cdn.pixelbin.io"# }frompixelbin.utils.urlimporturl_to_objcustomDomainUrl="https://xyz.designify.media/v2/z-slug/t.resize(h:100,w:200)~t.flip()/path/to/image.jpeg";obj=url_to_obj(customDomainUrl,opts={is_custom_domain:True})# obj# {#     "zone": "z-slug",#     "version": "v2",#     "transformations": [#         {#             "plugin": "t",#             "name": "resize",#             "values": [#                 {#                     "key": "h",#                     "value": "100"#                 },#                 {#                     "key": "w",#                     "value": "200"#                 }#             ]#         },#         {#             "plugin": "t",#             "name": "flip",#         }#     ],#     "filePath": "path/to/image.jpeg",#     "baseUrl": "https://xyz.designify.media",#     "wrkr": False,#     "workerPath": "",#     "options": {}# }workerUrl="https://cdn.pixelbin.io/v2/your-cloud-name/z-slug/wrkr/resize:h100,w:200/folder/image.jpeg";obj=url_to_obj(workerUrl)# obj# {#     "cloudName": "your-cloud-name",#     "zone": "z-slug",#     "version": "v2",#     "transformations": [],#     "filePath": "",#     "worker": True,#     "workerPath": "resize:h100,w:200/folder/image.jpeg",#     "baseUrl": "https://cdn.pixelbin.io"#     "options": {}# }### obj_to_urlConvertstheextractedurlobjtoaPixelbinurl.|Property|Description|Example||--------------------------|----------------------------------------------------|-------------------------------------||`cloudName`(string)|ThecloudnameextractedfromtheURL|`your-cloud-name`||`zone`(string)|6characterzoneslug|`z-slug`||`version`(string)|CDNAPIversion|`v2`||`transformations`(array)|ExtractedtransformationsfromtheURL|`[{"plugin":"t","name":"flip"}]`||`filePath`(string)|PathtothefileonPixelbinstorage|`/path/to/image.jpeg`||`baseUrl`(string)|BaseURL|`https://cdn.pixelbin.io/`||`isCustomDomain`(boolean)|IndicatesiftheURLisforacustomdomain|`False`||`worker`(boolean)|IndicatesiftheURLisaURLTranslationWorkerURL|`False`||`workerPath`(string)|InputpathtoaURLTranslationWorker|`resize:w200,h400/folder/image.jpeg`||`options`(Object)|Queryparametersadded,suchas"dpr"and"f_auto"|`{"dpr":2.0,"f_auto":True}`|```pythonfrompixelbin.utils.urlimportobj_to_urlobj={cloudName:"your-cloud-name",zone:"z-slug",version:"v2",options:{dpr:2.0,f_auto:True,},transformations:[{plugin:"t",name:"resize",values:[{key:"h",value:"100",},{key:"w",value:"200",},],},{plugin:"t",name:"flip",},],filePath:"path/to/image.jpeg",baseUrl:"https://cdn.pixelbin.io",}url=obj_to_url(obj)# obj is as shown above# url# https://cdn.pixelbin.io/v2/your-cloud-name/z-slug/t.resize(h:100,w:200)~t.flip()/path/to/image.jpeg?dpr=2.0&f_auto=trueUsage with custom domainfrompixelbin.utils.urlimportobj_to_urlobj={zone:"z-slug",version:"v2",transformations:[{plugin:"t",name:"resize",values:[{key:"h",value:"100",},{key:"w",value:"200",},],},{plugin:"t",name:"flip",},],filePath:"path/to/image.jpeg",baseUrl:"https://xyz.designify.media",isCustomDomain:True,};url=Pixelbin.utils.objToUrl(obj);# obj is as shown above# url# https://xyz.designify.media/v2/z-slug/t.resize(h:100,w:200)~t.flip()/path/to/image.jpegUsage with URL Translation Workerfrompixelbin.utils.urlimportobj_to_urlobj={cloudName:"your-cloud-name",zone:"z-slug",version:"v2",transformations:[],filePath:"",worker:True,workerPath:"resize:h100,w:200/folder/image.jpeg",baseUrl:"https://cdn.pixelbin.io",};url=Pixelbin.utils.objToUrl(obj);# obj is as shown above# url# https://cdn.pixelbin.io/v2/your-cloud-name/z-slug/wrkr/resize:h100,w:200/folder/image.jpegDocumentationAPI docs