Binance API : How to get Binance User ID using API - binance

How to get Binance User ID using API. I just created a bot and I need unique value to create a bot activation so a user can use my bot only for that account.
That is why I need a User ID by Binance API. How can I get a User ID or get any other unique value like a User ID by API.

Binance does not share any unique ID of each user, most likely for privacy reasons.
You can partially bypass this limitation by querying balances of each API key. If there are two API keys with the same set of balances, chances are it's the same user. Mind that this solution is not easily scalable. With thousands of users you'll have to run thousands of requests to get their balances. And probably cache these results, so that you don't run into rate limits (number of API requests from your server IP), which introduces another inaccuracies.

Related

Tracking multiple "Binance" orders for multiple users from a single connection

The task is as follows:
There is a list of users from Binance exchange, each user can create an order on the Binance exchange. It is necessary to implement a mechanism for tracking user orders on the Binance exchange through a single connection.
There are a lot of users. A lot of tokens and secret keys. One connection.
I use the node js library "binance-api-node".
But I am ready to hear any solutions to the problem.
Orders sent through the POST /api/v3/order endpoint (client.order() in the library) return a unique newClientOrderId (or you can specify your own and send it with the request payload). You can store it in your app in relation with the order and the user.
Orders that have been created using a different way (e.g. the Binance UI) are a little more complicated. You can receive the list of orders per API key, for example with the GET /api/v3/allOrders endpoint. Each order again contains a unique clientOrderId, and since you know the API key that you used to query these orders, you can make a relation between the clientOrderId and your user.
Note that each Binance account can have multiple API keys and there is no easy way to determine whether two API keys belong to the same Binance account or not. See this answer for more info.
Because each authenticated REST endpoint requires exactly one API key (and some endpoints also require exactly one corresponding secret key to sign the payload), it is not possible to communicate with the API on behalf of multiple API keys in a single connection.
You'll need to make a separate request for each of the API keys.

Can I create a quickbooks invoice on behalf of another user, in their account?

I am following Intuit's oAuth authentication guide in order to log users in through Quickbooks and get access/refresh tokens in order to make API calls. We make API calls in node through the node-quickbooks SDK.
I can successfully log users in through Quickbooks and exchange codes I receive for access and refresh tokens, and I can even make API calls to create invoices successfully.
The problem is, even when I use the tokens of the user I've authenticated to make API calls, the invoice is created in our Quickbooks company instead of theirs.
Is it possible to create invoices in the Quickbooks account of the other user? If not, what's the point of getting access and refresh tokens for them in the first place? For what it's worth, this is all being done in the Quickbooks developer sandbox (but with two separate accounts).
I'm quite confused as to what the methodology is supposed to be here, and any guidance would be very much appreciated -- or even just a reassurance that this is possible.
Thank you!
The QuickBooks instance that's acted on is determined by the Realm ID parameter. The Realm ID is captured when a QuickBooks Online account is selected during the authorization flow.
If we could call your Quickbooks company "Company A" and the one you're trying to create invoices in "Company B", I'd say it sounds like Company A's Realm ID is being logged and passed in subsequent requests instead of Company B's. This could be caused by things by hard-coding Company A's Realm ID and using that for the create invoices requests, selecting the wrong account during the authorization process, or something trickier like a bug in the SDK you're using.
I'd start by getting Company A and B's Company ID, which is what Intuit calls the Realm ID when you access it from the UI. You can do that while logged into a sandbox or production account by pressing Ctrl + Alt + ? in Windows or Control + Option + ? in macOS. Then you can verify the correct Realm ID is being used in the create invoice requests.
If the requests are using the value captured during authentication (as they should be), then you can —in the SDK code— log the Realm ID that's being captured during authorization and verify it's the right one for the company you selected during the OAuth flow.

NodeJs Multi-vendor site and product accessing

I've been working on a NodeJs web application that uses APi's and a number of differently branded Front-end's for different sellers. Sellers can list their product by visiting appropriate Front-End. However I've hit a problem where there is no logic preventing sellers accessing other seller accounts.
There are several API's that interact with the product, so an idea was to filter all API's against the seller ID to prevent the wrong seller accessing the wrong product. i.e When Seller A lists a product, an sellerID is recorded against product. So if Seller B tries to access the UpdateProducts API against Seller A product, their Login ID will not match the saved sellerID and it will be denied. I think this will work but checking access against products sounds taxing. Are there any better way to do this ?
Before accessing any data from database every request should be checked if it has token authorization. If token is valid, it is possible to get userId from token and search any data for the given userId.
P.S. This approach I'm using in REST API

Instagram graph api get amount of follows and followers

Trying to figure out a way to get the amount of follows and followers of a user via the Instagram-basic-display-api which is intended for consumer users.
I can only get the account_type, id, media_count, username
fields when doing a get on the user node
GET https://graph.instagram.com/{user-id}
?fields={fields}
&access_token={access-token}
Since the old Basic Instagram api https://www.instagram.com/developer/endpoints/users/#get_users_self supported the amount of follows and followers Im wondering if they are going to add this or if this is possible via another new Instagram endpoint?

Store data in Stripe to be sent back as part of web hook data?

I am working for the first time with Stripe. I am using stand alone accounts. I have a platform account also. In my web site a number of people with different Stripe accounts will be opening up campaigns for which money can be donated by various donors. Each campaign owner has a separate stripe account and the platform will be charging through the campaign owner's stripe account.
So what it amounts to is the platform account will be charging for a number of campaigns through each campaign owner's Stripe account. My problem is related to web hooks. One point to remember is each campaign has an id associated with it in the database and I am storing the API key of each campaign owner's stripe account and associating it with this id. To get Stripe data from the web hook in the web hook end point I have to set the API key of the connected account with a statement like:
\Stripe\Stripe::setApiKey("api key of stand alone account");
$input = #file_get_contents("php://input");
The trouble with this is there is one web hook end point for a number of Stripe accounts. I cannot hard-code the API key in the above statement. I have to fetch the appropriate API key from my database using the id.
But when Stripe invokes the web hook end point I simply do not have the campaign id with me in order to fetch the appropriate API key and set the API key. Is there any solution around this?
You don't need to store each account's API key. The only information you need to store is the account ID ("acct_..."). With standalone accounts, your integration will receive the account ID in the last step of the OAuth flow, in the stripe_user_id parameter.
You can then issue API requests on behalf of this account by using your own (the platform's) API key, and the Stripe-Account header.
Regarding webhooks specifically, events sent to your server via a "Connect" endpoint will include a user_id field with the account ID. So you can do something like this:
\Stripe\Stripe::setApiKey("PLATFORM_API_KEY");
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
$user_id = $event_json->user_id;
// if you need to send an API request on behalf of this account,
// for example if you want to verify the event by fetching it from
// Stripe, you can use the Stripe-Account header:
$event = \Stripe\Event::retrieve(
$event_json->id,
array("stripe_account" => $user_id)
);

Resources