OPSkins / trade-opskins-api

API docs for trade.opskins.com
41 stars 19 forks source link

How to get changed status codes #111

Closed AustinWildgrube closed 2 years ago

AustinWildgrube commented 5 years ago

So I am using the API to send trade offers which is working perfectly fine. My question is, how do I know when a trade offer is accepted or declined? I know there are ways of checking through other requests like

https://api-trade.opskins.com/ITrade/GetOffer/v1/

then looking at the state, but that kind of seems like an odd method especially when you don't know how long it will take a user to accept/decline the offer. Is there an IPN like what CoinPayments or Paypal has? I'm using PHP (Composer) for the requests.

ha1331 commented 5 years ago

That's how you do it, you'll have to implement logic that polls and tracks trade statuses. There is open issue for webhooks #30, from july so I wouldn't hold my breath waiting for it to be implemented.

ha1331 commented 5 years ago

as a sidenote, even if webhooks were introduced, you would likely want to implement some kind of logic that will be able to and does request trades statuses, because it's not like they are ever going to promise any kind of uptime or sanity for this. So many things that can go wrong with you trusting opskins/wax/what-ever to be 100% and if it's not 100%, you're going to be ddossing... polling them like the rest of us have been.

AustinWildgrube commented 5 years ago

@ha1331 Then what is all this nonsense?

https://gyazo.com/b0008fc18557dc9fafa56da9735238c9

I found it on here. I'm not too familiar with node.

https://waxexpresstrade-integrationguide.carrd.co/

ha1331 commented 5 years ago

This nonsense you are referring to, seem a lot like, what is widely know as, horse shit. Well, depends how you want to look at it. Technically what that says is true, I'm sure that thing fires an event when trade state is changed, but I suggest you scroll down the page, there's a clue: mgkbezj

const ET = new ExpressTrade({
apikey: 'YOUR_APIKEY',
twofactorsecret: 'THE_2FA_CODE_TO_THE_SAME_ACCOUNT_AS_THE_APIKEY',
pollInterval: 'HOW_OFTEN_YOU_WANT_TO_POLL' // In ms, example "5000". <--- raging clue
});

I assume who ever wrote that, implemented something that ... wait fooooor it ... polls opskins.

Doing what ever that tutorial says, I would not recommend it. This interaction with opskins is such a small, yet crucial aspect of what ever app, that I would prefer to implement it my self. When opskins goes steam, you really want to understand what your app is doing. There's no shortage of examples where this expressTrade thing has totally lived upto steamcommunity and gabens mood swings. Not saying this tutorial is invalid or poorly written, just food for thought.

AlaDyn172 commented 5 years ago

Hello,

Use this module: https://www.npmjs.com/package/expresstrade Install it correctly and then you can use:

ET.on('offerAccepted', (offer) => { // the offer object is an updated object after accepting it. });