fflogsapi


Namefflogsapi JSON
Version 2.1.2 PyPI version JSON
download
home_pageNone
SummaryPython client for the FF Logs v2 API
upload_time2024-11-16 14:41:46
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 GraphQL 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/)

---

## 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 command
to install development and test tools as well:

```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 access 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 access to enough data for the majority of
use cases.

If you need to access private information, you can configure the client to use user mode,
granting access to private information such as private reports.

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 you to log in. When logged in, the client gets
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/50/e1/ac0232d7c48d66eba96a99aba9aa02efaba8da007f90754b160682be531f/fflogsapi-2.1.2.tar.gz",
    "platform": null,
    "description": "# fflogsapi\n\nfflogsapi is a lazy Python 3 client for [FF Logs](https://www.fflogs.com/)' v2 GraphQL 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## 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 command\nto install development and test tools as well:\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 access 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 access to enough data for the majority of\nuse cases.\n\nIf you need to access private information, you can configure the client to use user mode,\ngranting access to private information such as private reports.\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 you to log in. When logged in, the client gets\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.2",
    "project_urls": {
        "Repository": "https://github.com/halworsen/fflogsapi"
    },
    "split_keywords": [
        "api",
        " client",
        " ffxiv",
        " fflogs",
        " lazy"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7414e0978940fdffec19febc71bfb29cbbc4c8b514debba5a9131a778ac10905",
                "md5": "bf76740cb26d7de70125f29bcbdc5cd6",
                "sha256": "f19c229e4e27c15b35bb7eb4f27a12d3f96637fe36a4cf3a537c800c7389a35c"
            },
            "downloads": -1,
            "filename": "fflogsapi-2.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf76740cb26d7de70125f29bcbdc5cd6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 63846,
            "upload_time": "2024-11-16T14:41:45",
            "upload_time_iso_8601": "2024-11-16T14:41:45.481366Z",
            "url": "https://files.pythonhosted.org/packages/74/14/e0978940fdffec19febc71bfb29cbbc4c8b514debba5a9131a778ac10905/fflogsapi-2.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50e1ac0232d7c48d66eba96a99aba9aa02efaba8da007f90754b160682be531f",
                "md5": "943870aeece5b94e061579797d62176d",
                "sha256": "2ff576d6200d85da850f83dcb74658f9efbce364d723debadda934e63e7222e1"
            },
            "downloads": -1,
            "filename": "fflogsapi-2.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "943870aeece5b94e061579797d62176d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 50129,
            "upload_time": "2024-11-16T14:41:46",
            "upload_time_iso_8601": "2024-11-16T14:41:46.549469Z",
            "url": "https://files.pythonhosted.org/packages/50/e1/ac0232d7c48d66eba96a99aba9aa02efaba8da007f90754b160682be531f/fflogsapi-2.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-16 14:41:46",
    "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.38598s