{"id":20206516,"url":"https://github.com/useflyyer/flyyer-python","last_synced_at":"2025-04-10T12:33:04.324Z","repository":{"id":47965419,"uuid":"286110888","full_name":"useflyyer/flyyer-python","owner":"useflyyer","description":"Python helpers to create https://flyyer.io URLs for link previews | Manage your og:images from a single dashboard","archived":false,"fork":false,"pushed_at":"2021-10-21T13:34:37.000Z","size":91,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T11:12:58.448Z","etag":null,"topics":["flyyer","image-generator","open-graph","poetry","python","twitter-cards"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/flyyer/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/useflyyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-08T19:58:48.000Z","updated_at":"2023-10-27T20:58:06.000Z","dependencies_parsed_at":"2022-08-12T15:21:04.732Z","dependency_job_id":null,"html_url":"https://github.com/useflyyer/flyyer-python","commit_stats":null,"previous_names":["flayyer/flayyer-python"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/useflyyer%2Fflyyer-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/useflyyer","download_url":"https://codeload.github.com/useflyyer/flyyer-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217123,"owners_count":21066633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flyyer","image-generator","open-graph","poetry","python","twitter-cards"],"created_at":"2024-11-14T05:24:34.926Z","updated_at":"2025-04-10T12:33:04.299Z","avatar_url":"https://github.com/useflyyer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flyyer-python\n\n![PyPI - Version](https://img.shields.io/pypi/v/flyyer) ![PyPI - Downloads](https://img.shields.io/pypi/dm/flyyer)\n\nThe AI-powered preview system built from your website (no effort required).\n\n![Flyyer live image](https://github.com/useflyyer/create-flyyer-app/blob/master/.github/assets/website-to-preview.png?raw=true\u0026v=1)\n\n**This module is agnostic to any Python framework.**\n\n## Index\n\n- [Get started (5 minutes)](#get-started-5-minutes)\n- [Advanced usage](#advanced-usage)\n- [Flyyer Render](#flyyer-render)\n- [Development](#development)\n- [Test](#test)\n\n## Get started (5 minutes)\n\nHaven't registered your website yet? Go to [Flyyer.io](https://flyyer.io?ref=flyyer-python) and create a project (e.g. `website-com`).\n\n### 1. Install the library\n\nThis module requires Python \u003e= 3.6.\n\nInstall it with [Poetry](https://python-poetry.org/).\n\n```sh\npoetry add flyyer\n```\n\nOr install it with [pip](https://pip.pypa.io/en/stable/).\n\n```sh\npip install flyyer\n```\n\n### 2. Get your Flyyer.io smart image link\n\nIn your website code (e.g. your landing or product/post view file), set the following:\n\n```python\nfrom flyyer import Flyyer\n\nflyyer = Flyyer(\n  # Your project slug\n  project=\"website-com\",\n  # The current path of your website\n  path=\"/path/to/product\", # In Django you can use {{ request.get_full_path }}\n  # (Optional, Recommended) Default or main image for each page\n  default=\"/static/image-1.png\" # or https://your-site.com/static/image-1.png\n)\n\n# Check:\nprint(flyyer.href())\n# \u003e https://cdn.flyyer.io/v2/website-com/_/__v=1618281823\u0026_def=%2Fstatic%2Fimage-1.png/path/to/product\n```\n\n### 3. Put your smart image link in your `\u003chead\u003e` tags\n\nYou'll get the best results like this:\n\n```python\n\u003cmeta property=\"og:image\" content=\"{{ flyyer.href() }}\"\u003e\n\u003cmeta name=\"twitter:image\" content=\"{{ flyyer.href() }}\"\u003e\n\u003cmeta name=\"twitter:card\" content=\"summary_large_image\"\u003e\n```\n\n### 4. Create a `rule` for your project\n\nGo to your dashboard [here](https://flyyer.io/dashboard/_/projects/_/manage) and create a rule like the following:\n\n[![Flyyer basic rule example](https://github.com/useflyyer/create-flyyer-app/blob/master/.github/assets/rule-example.png?raw=true\u0026v=1)](https://flyyer.io/dashboard)\n\nVoilà!\n\n## Advanced usage\n\nAdvanced features include:\n\n- Custom variables: additional information for your preview that is not present in your website. [Note: if you need customization you should take a look at [Flyyer Render](#flyyer-render)]\n- Custom metadata: set custom width, height, resolution, and more (see example).\n- Signed URLs.\n\nHere you have a detailed full example for project `website-com` and path `/path/to/product`.\n\n```python\nfrom flyyer import Flyyer, FlyyerMeta\n\nflyyer = Flyyer(\n  # [Required] Your project slug, find it in your dashboard https://www.flyyer.io/dashboard/_/projects/_/integrate.\n  project=\"website-com\",\n  # [Recommended] The current path of your website (by default it's `/`).\n  path=\"/path/to/product\",\n  # [Optional] In case you want to provide information that is not present in your page set it here.\n  variables={\n    \"title\": \"Product name\",\n    \"img\": \"https://flyyer.io/img/marketplace/flyyer-banner.png\",\n  },\n  # [Optional] Custom metadata for rendering the image. ID is recommended so we provide you with better statistics.\n  meta=FlyyerMeta(\n    id=\"jeans-123\", # recommended for better stats\n    v=\"12369420123\", # specific handler version, by default it's a random number to circumvent platforms' cache,\n    width=1200,\n    height=600,\n    resolution=0.9, # from 0.0 to 1.0\n    agent=\"whatsapp\", # force dimensions for specific platform\n  ),\n)\n\n# Check:\nprint(flyyer.href())\n# \u003e https://cdn.flyyer.io/v2/website-com/_/__v=1618281823/path/to/product\n```\n\nFor signed URLs, just provide your secret (find it in Dashboard \u003e Project \u003e Advanced settings) and choose a strategy (`HMAC` or `JWT`).\n\n```python\nflyyer = Flyyer(\n  project=\"website-com\",\n  path=\"/path/to/product\",\n  secret=\"your-secret-key\",\n  strategy=\"JWT\", # or 'HMAC'\n)\n\nprint(flyyer.href())\n# \u003e https://cdn.flyyer.io/v2/website-com/jwt-eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJwYXJhbXMiOnsiX19pZCI6ImplYW5zLTEyMyJ9LCJwYXRoIjoiXC9wYXRoXC90b1wvcHJvZHVjdCJ9.X8Vs5SGEA1-3M6bH-h24jhQnbwH95V_G0f-gPhTBTzE?__v=1618283086\n```\n\n## Flyyer Render\n\nAs you probably realized, **Flyyer** uses the [rules defined on your dashboard](https://flyyer.io/dashboard/_/projects) to decide how to handle every image based on path patterns. It analyses your website to obtain information and then render a content-rich image with no effort. Let's say _\"Flyyer delivers images based on the content of this route\"_.\n\n**Flyyer Render** instead requires you to explicitly declare template and variables for the images to render, **giving you more control for customization**. Let's say _\"FlyyerRender delivers an image using this template and these explicit variables\"_.\n\n```python\nfrom flyyer import FlyyerRender\n\nflyyer = FlyyerRender(\n    tenant=\"tenant\",\n    deck=\"deck\",\n    template=\"template\",\n    variables={\"title\": \"Hello world!\"},\n)\n\n# Use this image in your \u003chead/\u003e tags\nurl = flyyer.href()\n# \u003e https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?__v=1596906866\u0026title=Hello+world%21\n```\n\nVariables can be complex arrays and hashes.\n\n```python\nfrom flyyer import FlyyerRender, FlyyerMeta\n\nflyyer = FlyyerRender(\n    tenant=\"tenant\",\n    deck=\"deck\",\n    template=\"template\",\n    variables={\n        \"items\": [\n            { \"text\": \"Oranges\", \"count\": 12 },\n            { \"text\": \"Apples\", \"count\": 14 },\n        ],\n    },\n    meta=FlyyerMeta(\n        id=\"slug-or-id\", # To identify the resource in our analytics report\n    ),\n)\n```\n\nYou can use signatures with Flyyer Render like below.\n\n```python\nfrom flyyer import FlyyerRender\n\nflyyer = FlyyerRender(\n    tenant=\"tenant\",\n    deck=\"deck\",\n    template=\"template\",\n    variables={\"title\": \"Hello world!\"},\n    secret=key,\n    strategy=\"HMAC\", # JWT\n)\n\n# Use this image in your \u003chead/\u003e tags\nurl = flyyer.href()\n# \u003e https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?__v=d+\u0026title=Hello+world%21\u0026__hmac=1bea6d523496848c\n```\n\n**IMPORTANT: variables must be serializable.**\n\nTo decode the URL for debugging purposes:\n\n```python\nfrom urllib.parse import unquote\n\nprint(unquote(url))\n# \u003e https://cdn.flyyer.io/render/v2/tenant/deck/template.jpeg?title=Hello+world!\u0026__v=123\n```\n\n## Development\n\nPrepare the local environment:\n\n```sh\npoetry install\n```\n\n```sh\npoetry shell\n```\n\nDeploy with:\n\n```sh\n# Set API Token\npoetry config pypi-token.pypi pypi-TOKEN\n\npoetry version X.Y.Z\npoetry build\npoetry publish\n```\n\n## Test\n\nRun tests with pytest:\n\n```sh\npoetry run pytest\n```\n\nRun [black](https://github.com/psf/black) linter:\n\n```sh\nblack .\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuseflyyer%2Fflyyer-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuseflyyer%2Fflyyer-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuseflyyer%2Fflyyer-python/lists"}