Replies: 5 comments 7 replies
-
Solution: When creating a new Client you will need to save some sort of a map, e.g. # First we obtain the user UUID somewhere (e.g. from the database) and pass it into the function above.
async def set_traffic_limit(telegram_id: int, user_uuid: str) -> None:
client = await api.client.get_by_email(str(telegram_id)) # Getting the client from API.
client.id = user_uuid # Updating the client ID to correct UUID (e.g. from the database).
client.total_gb = gigabytes_to_bytes(10) # Just for reference, setting the traffic limit for a Client to 10 Gb.
await api.client.update(user_uuid, client) # Updating the client. |
Beta Was this translation helpful? Give feedback.
-
You can get it through get_inbounds() method, like that: inbounds = await get_inbounds()
inbound = inbounds[0]
id = inbound.settings.clients[0].id |
Beta Was this translation helpful? Give feedback.
-
As @Goosegit11 mentioned earlier, this endpoint returns the actual UUIDs, I can confirm that. Here's a short snippet of how to obtain Clients with the actual UUIDs (not numeric IDs).
|
Beta Was this translation helpful? Give feedback.
-
What is the problem? I have already found the user's UUID, but the update still doesn't happen? |
Beta Was this translation helpful? Give feedback.
-
@ra1nbow1, hey! I strongly recommend that you check the data you receive from the API before making new requests. Client from the inbounds endpoint: Client from the get_by_email endpoint: So in your case, this approach indeed won't work because 3x-ui API does not return the inbound ID and I guess the API just doesn't know where to update it.
Otherwise, if the application developers at some point make changes to the API, this will lead to the library losing compatibility with the current version and/or backward compatibility with older versions, which is not the desired outcome for me. I also expect that this library is used by developers, not end users, and therefore has all the necessary functionality for debugging, checking the values received, as well as checking the payloads sent. In this particular case, I am a little confused by the fact that debugging this issue required two print commands for the responses received from different endpoints. Despite the fact that I myself, as a developer, do not find it very convenient to work with 3x-ui API, and as a library developer, I also encountered a number of problems due to the inconsistency of the responses, I would also ask you to refrain from any negativity towards the developers of the panel since this is a great open source project, which is handled by a small number of people, and therefore it is quite expected that it may not work perfectly. I'm going to stop discussing this issue here and encourage developers to take a closer look at the code and data they work with, because I feel like the entire debugging process that was done in these issues was feeding pieces of code and errors into ChatGPT without any attempt to simply see what's inside. And that really upsets me. @P1f1, I believe your question is similar to what I discussed above. However, of course, if you find a bug in the library, you can always open an issue, but please first check your payloads, data and refer to the official API documentation, links to each method are in the docstrings. Best Regards |
Beta Was this translation helpful? Give feedback.
-
Problem: The 3x-ui API does not return the actual Client UUID, it's returning just numerical ID, while for updating a client you'll need to know its UUID.
UPD: Working solution is here:
As @Goosegit11 mentioned earlier, this endpoint returns the actual UUIDs, I can confirm that.
Here's a short snippet of how to obtain Clients with the actual UUIDs (not numeric IDs).
Beta Was this translation helpful? Give feedback.
All reactions