Search code examples
bashcurlget

CURL to a website API respondsdifferent result


As the title says, im using firefox network explorer to consume an API, i've copied several things sucessfully like this, but this one gives a different result

So, in the web the query is a GET to https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL and the response a valid JSON (At least both Firefox and Chrome shows this)

{"code":"000000","message":"null","messageDetail":null,"data":[{"asset":"USDT","list":[{"projectId":"CUSDT7DAYS001","projectName":"USDT","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"224565","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDT","interestRate":"0.06310000","interestPerLot":"0.12090000","duration":"7","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"1"},{"projectId":"CUSDT14DAYSS001","projectName":"USDT","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"190167","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDT","interestRate":"0.06480000","interestPerLot":"0.24860000","duration":"14","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"1"},{"projectId":"CUSDT30DAYSS001","projectName":"USDT","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"676977","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDT","interestRate":"0.06660000","interestPerLot":"0.54720000","duration":"30","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"1"},{"projectId":"CUSDT90DAYSS001","projectName":"USDT","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"969489","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDT","interestRate":"0.07000000","interestPerLot":"1.72700000","duration":"90","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"1"}]},{"asset":"BUSD","list":[{"projectId":"CBUSD7DAYS001","projectName":"BUSD","lotsUpLimit":"500000","lotsLowLimit":"1","lotsPurchased":"30744","maxLotsPerUser":"100000","lotSize":"100.00000000","asset":"BUSD","interestRate":"0.06310000","interestPerLot":"0.12090000","duration":"7","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"2"},{"projectId":"CBUSD14DAYSS001","projectName":"BUSD","lotsUpLimit":"500000","lotsLowLimit":"1","lotsPurchased":"20988","maxLotsPerUser":"100000","lotSize":"100.00000000","asset":"BUSD","interestRate":"0.06480000","interestPerLot":"0.24860000","duration":"14","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"2"},{"projectId":"CBUSD30DAYSS001","projectName":"BUSD","lotsUpLimit":"500000","lotsLowLimit":"1","lotsPurchased":"151414","maxLotsPerUser":"100000","lotSize":"100.00000000","asset":"BUSD","interestRate":"0.06660000","interestPerLot":"0.54720000","duration":"30","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"2"},{"projectId":"CBUSD90DAYSS001","projectName":"BUSD","lotsUpLimit":"500000","lotsLowLimit":"1","lotsPurchased":"204698","maxLotsPerUser":"100000","lotSize":"100.00000000","asset":"BUSD","interestRate":"0.07000000","interestPerLot":"1.72700000","duration":"90","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"2"}]},{"asset":"USDC","list":[{"projectId":"USDC7DAYSS001","projectName":"USDC","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"26688","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDC","interestRate":"0.05310000","interestPerLot":"0.10180000","duration":"7","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"3"},{"projectId":"USDC14DAYSS001","projectName":"USDC","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"19296","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDC","interestRate":"0.05480000","interestPerLot":"0.21010000","duration":"14","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"3"},{"projectId":"USDC30DAYSS001","projectName":"USDC","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"20059","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDC","interestRate":"0.05660000","interestPerLot":"0.46520000","duration":"30","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"3"},{"projectId":"USDC90DAYSS001","projectName":"USDC","lotsUpLimit":"2000000","lotsLowLimit":"1","lotsPurchased":"94209","maxLotsPerUser":"500000","lotSize":"100.00000000","asset":"USDC","interestRate":"0.06000000","interestPerLot":"1.47940000","duration":"90","needKyc":false,"canAutoRenew":true,"withWhiteList":false,"withAreaLimitation":false,"status":"PURCHASING","displayPriority":"3"}]}],"total":3,"success":true}

But then, when i try to use curl to this same site, it throws a generic web error

curl https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL 
HTTP/1.1 404 Not Found
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Date: Tue, 09 Feb 2021 21:19:48 GMT
Server: Tengine
Vary: Accept-Encoding
ETag: W/"5ff3db87-197a"
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: origin-when-cross-origin
Strict-Transport-Security: max-age=31536000; includeSubdomains
Content-Encoding: gzip
X-Cache: Error from cloudfront
Via: 1.1 da12738b8eacc0d543b2915c5e4262dd.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: SYD1-C2
X-Amz-Cf-Id: xS7LR0Qvm4onqjXxgaA7IG6LPrYNk3VJ0hFV0wFvk2Vk7oPTrRk8jw==

The site that loads this api is https://www.binance.com/en/earn#fixed-item

Here are some screenshots

enter image description here enter image description here


Solution

  • I managed o make it work with some extras in curl curl -XGET -H "Content-type: application/json" 'https://www.binance.com/gateway-api/v1/friendly/lending/project/customizedFixedProject/list?pageSize=3&pageIndex=1&status=ALL'