fflogsapi


Namefflogsapi JSON
Version 2.1.1 PyPI version JSON
download
home_pageNone
SummaryPython client for the FF Logs v2 API
upload_time2024-04-25 18:52:21
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords api client ffxiv fflogs lazy
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # fflogsapi

fflogsapi is a lazy Python 3 client for [FF Logs](https://www.fflogs.com/)' v2 API with query caching functionality.

[![Tests](https://github.com/halworsen/fflogsapi/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/halworsen/fflogsapi/actions/workflows/test.yml)
[![Linting](https://github.com/halworsen/fflogsapi/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/halworsen/fflogsapi/actions/workflows/lint.yml)
[![codecov](https://codecov.io/gh/halworsen/fflogsapi/branch/master/graph/badge.svg?token=YTEGMDJOGL)](https://codecov.io/gh/halworsen/fflogsapi)
[![Documentation Status](https://readthedocs.org/projects/fflogsapi/badge/?version=latest)](https://fflogsapi.readthedocs.io/en/latest/?badge=latest)
[![pypi](https://shields.io/pypi/v/fflogsapi)](https://pypi.org/project/fflogsapi/)

---

## Features

* Retrieve information from FF Logs' v2 GraphQL API
  * Including private information only accessible through the user API
* Lazy evaluation
  * Queries for data are not executed until the result is explicitly needed
* Query caching
  * Requesting the same data twice will instead fetch the result from cache
  * Customizable cache lifetime and options to ignore cached results

## Installation

fflogsapi is available as a [PyPI package](https://pypi.org/project/fflogsapi/) and
can be installed with pip:

```shell
pip install fflogsapi
```

If you want to contribute, you can install fflogsapi with the following to
additionally install development and test tools:

```shell
pip install fflogsapi[dev,test]
```

## Example usage

Calculating damage done under pots:

```python
from config import CLIENT_ID, CLIENT_SECRET

from fflogsapi import FFLogsClient

client = FFLogsClient(CLIENT_ID, CLIENT_SECRET)
report = client.get_report('rGARYmQwTKbahXz9')

for fight in report:
    print(f'Fight #{fight.id}:', fight.name(), f'- Kill: {fight.is_kill()}')
    pot_table = fight.table(filters={'sourceAurasPresent': 'Medicated'})
    potted_damage = 0
    for damage in pot_table['damageDone']:
        potted_damage += damage['total']
    print(f'Damage done under pots: {potted_damage}')
    if not fight.is_kill():
        print(f'Percentage reached: {fight.percentage()}')

client.close()
client.save_cache()
```

Listing reports and durations for a specific guild:

```python
from config import CLIENT_ID, CLIENT_SECRET

from fflogsapi import FFLogsClient

client = FFLogsClient(CLIENT_ID, CLIENT_SECRET)
for page in client.reports(filters={ 'guildID': 80551 }):
    print(f'Reports in page: {page.count()}')
    for report in page:
        print(report.title(), f'Duration: {report.duration()}')

client.close()
client.save_cache()
```

Listing a character's RDPS & All stars rank for Abyssos Savage in 6.28:

```python
from config import CLIENT_ID, CLIENT_SECRET

from fflogsapi import FFLogsClient, GQLEnum, FightDifficulty

client = FFLogsClient(CLIENT_ID, CLIENT_SECRET)
character = client.get_character(id=19181640)

abyssos = client.get_zone(id=49)
partition_628 = next(filter(
    lambda p: '6.28' in p.name,
    abyssos.partitions()
))

rankings = character.zone_rankings(filters={
    'specName': 'Reaper',
    'metric': GQLEnum('rdps'),
    'zoneID': abyssos.id,
    'difficulty': FightDifficulty.SAVAGE.value,
    'partition': partition_628.id,
})

print('6.28 All Star points: '
      f'{rankings.all_stars[0].points} (rank {rankings.all_stars[0].rank})')

for rank in rankings.encounter_ranks:
    print(f'{rank.encounter.name()}: {rank.best_amount}rdps (rank {rank.all_stars.rank})')

client.close()
client.save_cache()
```

## User mode

The default mode of the client is 'client' mode, which uses the public API. This is by far the most
convenient method to use the client, and usually provides enough functionality for the majority of
use cases.

If you need access to private information, however, it is possible to use the client in user mode,
granting access to extra information such as private reports provided by the user API.

To use user mode, you must first specify `https://localhost:4433` as the redirect URL in your API
client on FF Logs. Then, provide the `mode='user'` kwarg to the client when instantiating it:

```python
client = FFLogsClient(CLIENT_ID, CLIENT_SECRET, mode='user')
```

This will have the client popup a browser window for the user for login, after which the client has
access to the user API. Note that the client will generate a self-signed certificate to serve
the redirect. Your browser will likely produce a warning about this, although it is safe to ignore.

If you wish to handle the user authentication flow yourself, you can still use the API client in
user mode by calling `set_auth_response` on the client **before using it**:

```python
# Your implementation of the user authentication flow here
...

client = FFLogsClient(CLIENT_ID, CLIENT_SECRET, mode='user')
client.set_auth_response(response)

# Start using the client
...
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fflogsapi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "api, client, ffxiv, fflogs, lazy",
    "author": null,
    "author_email": "Markus Wang Halvorsen <mwh@halvorsenfamilien.com>",
    "download_url": "https://files.pythonhosted.org/packages/59/ca/9800594158c4f19945028c3c6b00f263e3f40dbca1d19fc4c724b224800c/fflogsapi-2.1.1.tar.gz",
    "platform": null,
    "description": "# fflogsapi\n\nfflogsapi is a lazy Python 3 client for [FF Logs](https://www.fflogs.com/)' v2 API with query caching functionality.\n\n[![Tests](https://github.com/halworsen/fflogsapi/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/halworsen/fflogsapi/actions/workflows/test.yml)\n[![Linting](https://github.com/halworsen/fflogsapi/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/halworsen/fflogsapi/actions/workflows/lint.yml)\n[![codecov](https://codecov.io/gh/halworsen/fflogsapi/branch/master/graph/badge.svg?token=YTEGMDJOGL)](https://codecov.io/gh/halworsen/fflogsapi)\n[![Documentation Status](https://readthedocs.org/projects/fflogsapi/badge/?version=latest)](https://fflogsapi.readthedocs.io/en/latest/?badge=latest)\n[![pypi](https://shields.io/pypi/v/fflogsapi)](https://pypi.org/project/fflogsapi/)\n\n---\n\n## Features\n\n* Retrieve information from FF Logs' v2 GraphQL API\n  * Including private information only accessible through the user API\n* Lazy evaluation\n  * Queries for data are not executed until the result is explicitly needed\n* Query caching\n  * Requesting the same data twice will instead fetch the result from cache\n  * Customizable cache lifetime and options to ignore cached results\n\n## Installation\n\nfflogsapi is available as a [PyPI package](https://pypi.org/project/fflogsapi/) and\ncan be installed with pip:\n\n```shell\npip install fflogsapi\n```\n\nIf you want to contribute, you can install fflogsapi with the following to\nadditionally install development and test tools:\n\n```shell\npip install fflogsapi[dev,test]\n```\n\n## Example usage\n\nCalculating damage done under pots:\n\n```python\nfrom config import CLIENT_ID, CLIENT_SECRET\n\nfrom fflogsapi import FFLogsClient\n\nclient = FFLogsClient(CLIENT_ID, CLIENT_SECRET)\nreport = client.get_report('rGARYmQwTKbahXz9')\n\nfor fight in report:\n    print(f'Fight #{fight.id}:', fight.name(), f'- Kill: {fight.is_kill()}')\n    pot_table = fight.table(filters={'sourceAurasPresent': 'Medicated'})\n    potted_damage = 0\n    for damage in pot_table['damageDone']:\n        potted_damage += damage['total']\n    print(f'Damage done under pots: {potted_damage}')\n    if not fight.is_kill():\n        print(f'Percentage reached: {fight.percentage()}')\n\nclient.close()\nclient.save_cache()\n```\n\nListing reports and durations for a specific guild:\n\n```python\nfrom config import CLIENT_ID, CLIENT_SECRET\n\nfrom fflogsapi import FFLogsClient\n\nclient = FFLogsClient(CLIENT_ID, CLIENT_SECRET)\nfor page in client.reports(filters={ 'guildID': 80551 }):\n    print(f'Reports in page: {page.count()}')\n    for report in page:\n        print(report.title(), f'Duration: {report.duration()}')\n\nclient.close()\nclient.save_cache()\n```\n\nListing a character's RDPS & All stars rank for Abyssos Savage in 6.28:\n\n```python\nfrom config import CLIENT_ID, CLIENT_SECRET\n\nfrom fflogsapi import FFLogsClient, GQLEnum, FightDifficulty\n\nclient = FFLogsClient(CLIENT_ID, CLIENT_SECRET)\ncharacter = client.get_character(id=19181640)\n\nabyssos = client.get_zone(id=49)\npartition_628 = next(filter(\n    lambda p: '6.28' in p.name,\n    abyssos.partitions()\n))\n\nrankings = character.zone_rankings(filters={\n    'specName': 'Reaper',\n    'metric': GQLEnum('rdps'),\n    'zoneID': abyssos.id,\n    'difficulty': FightDifficulty.SAVAGE.value,\n    'partition': partition_628.id,\n})\n\nprint('6.28 All Star points: '\n      f'{rankings.all_stars[0].points} (rank {rankings.all_stars[0].rank})')\n\nfor rank in rankings.encounter_ranks:\n    print(f'{rank.encounter.name()}: {rank.best_amount}rdps (rank {rank.all_stars.rank})')\n\nclient.close()\nclient.save_cache()\n```\n\n## User mode\n\nThe default mode of the client is 'client' mode, which uses the public API. This is by far the most\nconvenient method to use the client, and usually provides enough functionality for the majority of\nuse cases.\n\nIf you need access to private information, however, it is possible to use the client in user mode,\ngranting access to extra information such as private reports provided by the user API.\n\nTo use user mode, you must first specify `https://localhost:4433` as the redirect URL in your API\nclient on FF Logs. Then, provide the `mode='user'` kwarg to the client when instantiating it:\n\n```python\nclient = FFLogsClient(CLIENT_ID, CLIENT_SECRET, mode='user')\n```\n\nThis will have the client popup a browser window for the user for login, after which the client has\naccess to the user API. Note that the client will generate a self-signed certificate to serve\nthe redirect. Your browser will likely produce a warning about this, although it is safe to ignore.\n\nIf you wish to handle the user authentication flow yourself, you can still use the API client in\nuser mode by calling `set_auth_response` on the client **before using it**:\n\n```python\n# Your implementation of the user authentication flow here\n...\n\nclient = FFLogsClient(CLIENT_ID, CLIENT_SECRET, mode='user')\nclient.set_auth_response(response)\n\n# Start using the client\n...\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for the FF Logs v2 API",
    "version": "2.1.1",
    "project_urls": {
        "Repository": "https://github.com/halworsen/fflogsapi"
    },
    "split_keywords": [
        "api",
        " client",
        " ffxiv",
        " fflogs",
        " lazy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b0df132a2643b5a1d53c41be3105bea1150d9ecbd84234f9b5e09a7f597503d",
                "md5": "b5f4a10865938157161ba168642d948e",
                "sha256": "889aebe4785941ac4ac349f6dbb28ebab45e324eba4ce5725295a51d4a4b4f34"
            },
            "downloads": -1,
            "filename": "fflogsapi-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b5f4a10865938157161ba168642d948e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 64024,
            "upload_time": "2024-04-25T18:52:19",
            "upload_time_iso_8601": "2024-04-25T18:52:19.320719Z",
            "url": "https://files.pythonhosted.org/packages/8b/0d/f132a2643b5a1d53c41be3105bea1150d9ecbd84234f9b5e09a7f597503d/fflogsapi-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59ca9800594158c4f19945028c3c6b00f263e3f40dbca1d19fc4c724b224800c",
                "md5": "cb98c5a291249b294d8a9592686c8174",
                "sha256": "1ebae2b7af1e1a2ccba68bcbb54aa83d93e8f8d9dff1d97910745a42830fcb46"
            },
            "downloads": -1,
            "filename": "fflogsapi-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cb98c5a291249b294d8a9592686c8174",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 50451,
            "upload_time": "2024-04-25T18:52:21",
            "upload_time_iso_8601": "2024-04-25T18:52:21.126575Z",
            "url": "https://files.pythonhosted.org/packages/59/ca/9800594158c4f19945028c3c6b00f263e3f40dbca1d19fc4c724b224800c/fflogsapi-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-25 18:52:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "halworsen",
    "github_project": "fflogsapi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "fflogsapi"
}
        
Elapsed time: 0.38905s