Python SDK: GET-ing a project's translation statistics

I am trying to GET Get resource language stats collection using the Python SDK.

Here’s how I am trying:

from transifex.api import transifex_api

organization_slug = "my_organization"
project_slug = "my_project"

organization = transifex_api.Organization.get(slug=organization_slug)
projects = organization.fetch("projects")
project = projects.get(slug=project_slug)
project_stats = transifex_api.ResourceLanguageStats(project=project)

This doesn’t seem right though, as project_stats (if displayed as a dictionary) doesn’t seem to hold the desired data:

{'type': 'resource_language_stats', 'relationships': {'project': {'data': {'type': 'projects', 'id': 'o:my_organization:p:my_project'}}}}

Any clue on what I am doing wrong?

1 Like

Hello @MrNycticorax,

Thank you for reaching out to Transifex support.
Could you please confirm the information expected? Also, could you share the link where you found transifex_api.ResourceLanguageStats ?, I will like to perform further testing :slight_smile:

Thanks in advance
Cesar

1 Like

Thanks for stepping in @Cesar_Garcia, I cannot confirm the information expected any further than pointing you to this endpoint as that’s exactly the information I am trying to retrieve – but I need to use the Python SDK.

As for the exact class you’re asking about, see the screenshot; it’s on the last line:

1 Like

Hello ,

Allow me to step in and provide some isnight from our devs.

You were actually really close.
Just correct last line with

project_stats = transifex_api.ResourceLanguageStats.filter(project=project)

and for displaying the data you may use

for stat in project_stats : print(stat.attributes)

Let us know if we can help you further.
Kind regards
Christos

1 Like

Thanks for the kind and accurate answer, very grateful to the developer who took the time to look into my snippet!

1 Like

We are glad we could be of service.

Feel free to contact us at any time.

Kind regards
Christos

1 Like