Giter Site home page Giter Site logo

futbot's Introduction

DISCLAIMER

This project is not actively maintained anymore. I recently made it public. It was designed and heavily tested with FIFA21 only (Although EA wouldn't to drastic changes to their APIs).
If you want to fork the project and align with newer versions of the game, feel free to do so.
Project architecture in short:
There are 2 integral parts:

  • Node server with actual automation and querying
  • Chrome extension to change fut web app (buttons and info on player icons etc) and steal your own auth token. Chrome extension can talk to node server to automate some parts.

FutBot

This is a data source/trade bot for FIFA 21 fut api written in Typescript/Javascript for node.js.
To inject your session into node server, there is a chrome extension in the project. This extension is also drawing on fut web app, so that you can access features easily. It's tested with FIFA 21

Buy me a beer

You can donate to my paypal if you'd like.

Table of contents

Use Latest stable version

Dev Mode
Prepare (Dev Mode)
Start (Dev Mode)

Existing features
Existing UI Features

What to do on errors
Disclaimer and Notes
Known Bugs

Discord

Use Latest stable version

Go to releases page and select 'futbot.zip' under assest of latest stable version.
In this file you'll find executable version for server and ready to use chrome extension.
Activate developer mode in chrome://extensions page and click 'Load Unpacked' to load Futbot extension. The extension is there to read your session data and send it to server, so it's essential. If you get new version of the extension, you need to load it again. There is no automatic update because I cannot put this extension to chrome market.
When you are done with the extension, you can start the server. Server needs .env file to be present in the same directory, so that you can configure necessary parameters (In future this will be moved to UI). Note, whenever you need to change something in .env file, you need to restart the server.
Now you are all set to use existing features described later in this documentation.
Note for people outside of Europe: You need to change 'FUTBOT_FUT_API_ENDPOINT_OVERWRITE' value in .env file. Once you load the extension, go to fut web app and click to Futbot extension. It should tell you the endpoint. Just use that value and restart your server.

Dev Mode

If you have an issue starting the server from last stable version, you can execute the app directly from source code. Or if you know what you are doing, just use dev mode :)

Prepare (Dev Mode)

Node and yarn
Install node and yarn. Installing yarn via installation scripts are generally easier.

Config
The server needs a configuration file (.env) in order to get some user preferences and region based api endpoint. You can copy .env.local file as .env file in packages/server folder.
Don't forget to read what's inside .env file.

Start (Dev Mode)

Start the server and extension watch mode

$ yarn
$ yarn dev

Load the extension in developer mode to chrome. Build output should be under packages/extension/build.
Once you load it and if you are always using dev mode, you don't need to load it again. It'll be automatically updated.
Login to fut web app so that the extension can steal your session and inject it into node server. Since this server is not intented to be deployed somewhere, there is no session in node server. Instead, your Fut web app session will be shared for any task in the server.

Existing features:

How Jobs Work

In futbot, there are different apps such as '/trade-bot', '/invest' and 'auto-buyer'.
Each app comes with it's own different jobs.

To start a job, you can simply call
/<app-name>/start-<job-name>?<parameters-if-any>

To stop a job till you start/restart again
/<app-name>/stop-<job-name>?<parameters-if-any>

If you want to restart a job with new parameters:
/<app-name>/restart-<job-name>?<parameters-if-any>
Note: this will clear your report for that job.

If you want to finish a job:
/<app-name>/finish-<job-name>?<parameters-if-any>

Club

http://localhost:9999/club/non-squad-players
This just returns your players in club which are not in your actice squad and not in trade pile.
The list would be used for /trade-bot/start-selling job.

Trade Bot

http://localhost:9999/trade-bot/start-sell-unused?maxRating=83
These will control selling players who are not in your active squad. Once in a while it gets your players from club, figures a good price according to futbin/fut market data. And sells them if prices are trustable enough.

http://localhost:9999/trade-bot/start-sell-trade-pile
Relisting job is pretty similar to selling unused players. Only difference is, this job will only focus on players in your trade pile. It can relist an item or you can send players to transfer list and start this job to start selling them.

http://localhost:9999/trade-bot/clear-pile
This will clear transfer list from sold/expired items. It will send everything to club. If there are duplicates, it'll sell them.

Investor

Investor jobs lets you give a futbin page as your target pool for buy/sell actions.
Once you open like below, you'll see a button 'Add Target Page'.

Just press the button to add targets for investor app.
Adding a target will automatically start auto buyer job.
If you wish to control it, please do so from following endpoints:
http://localhost:9999/invest/start-auto-buy
http://localhost:9999/invest/stop-auto-buy
http://localhost:9999/invest/restart-auto-buy
http://localhost:9999/invest/finish-auto-buy
NOTE: You can always save your jobs (with added targets).

Auto Buyer

http://localhost:9999/auto-buyer/start-buy-now
http://localhost:9999/auto-buyer/start-buy-query
Endpoints to control auto buyer jobs. You don't need to start these as they will be automatically started once you add a target player or target query.

http://localhost:9999/auto-buyer/targets
It'll list your target players and target queries if any.

Sniping Players (Auto Buy Now):
Auto buyer feature is activated from futbot additions to UI.
Whenever you see a player, there will be a triangle icon to show player details and add target options. You can specify a buy value for this target and auto buyer will try to buy him for less than the price you provided.
You can optionaly provide a sell price. If a sell price is present, targets will be immediately sold.
If you wish to change buy value or sell value, just search the same target and add him again with new values.

Sniping search results (Auto Query):
You can also search your last transfer search from transfer results page. This feature is really similar to sniping players. Only difference is, auto buy query will buy whatever pops up for your query. So, you don't need to specify a price limit, as you can already specify it in your search criteria.
However you can still specify a sell price, which works exactly as in players.

Here is an example of auto buy query, which tries to buy any special player under 3000 coins. They will be sold for 4400.

NOTE: In order to bypass EA caches, min current bid and min buy now filters are automatically set. Don't use min current bid and min buy now values, otherwise you'll get an error (460);

DISCLAIMER: This feature will buy whatever pops up after your query. Which means, it can buy more than 50 player in less than 10 seconds. Use really carefully!

General

http://localhost:9999/jobs/list
http://localhost:9999/jobs/stop-all
http://localhost:9999/jobs/resume-all
These endpoints are pretty straitghforward. They show an overall look of currently running tasks/jobs. They also include their individual reports.

http://localhost:9999/jobs/save-jobs
http://localhost:9999/jobs/load-jobs
You can save & load the jobs through these endpoints.
Saving jobs will only save currently running jobs into a file called jobs.json. Feel free to modify this file without breaking the formatting.
Once you saved current jobs, you can load them in your next run.

http://localhost:9999/jobs/start-slow-down?min=15&max=45
This is a job which will be sleeping for FUTBOT_SLOW_DOWN_JOB_DURATION of time (.env file).
You can also configure how frequent this will be by setting FUTBOT_JOB_IMP_SLOW_DOWN value in .env file.

http://localhost:9999/stats
Shows statistics about api usage for fut & futbin.

http://localhost:9999/feedback
Feedback combines /stats, /jobs/list and .env file values to show state of your application.
It's usefull when you want to ask a question, report a bug, give a feedback or just share big profits!

Pricing

Futbot calculates pricing always from actual market. While doing the caculation, it uses futbin as a filter.
Checking price information of a player follows below steps:

  • Get futbin price of the player
  • Search market with max bay value as 130% of futbin price.
  • If there are less than 2 results, increase max buy price by 5% and continue searching.
  • If there are more than 10 results, get lowest buy now value in the results and search again with that value.
  • Stop after FUTBOT_MAX_PRICING_SEARCH_TRY tries (defined in .env).
  • If a price cannot be found in FUTBOT_MAX_PRICING_SEARCH_TRY tries but we already checked more than 10 samples, calculate price depending on those samples.

Quick Selling

Futbot can sell a player in many different jobs. Whenever it's trying to sell a player, quick sell price of the relevant player will be checked. If optimal selling price is too close to quick sell price, player will be discarded.
The value is controlled with FUTBOT_QUICK_SELL_MARGIN value defined in .env file. Default value is 200. Set to 0 to disable.
Example: One player has optimal sell price of 750. But it can be quick sold for 603. Futbot will choose to discard player with FUTBOT_QUICK_SELL_MARGIN=200 value. If you set FUTBOT_QUICK_SELL_MARGIN=100, Futbot will send the player to transfer list.

Existing UI Features

Player prices:
Add auto buy target:
The extension will add small visual components to players.

What to do on errors

Once in a while you'll get authentication errors from futbin and fut. The reason would be either fut session expired (401,403), fut requires validation (458) or futbin temporary ban (403).
The application stops after receiving these errors. But you need to refresh fut web app and login again, so that the extension can send new auth token to the server. After this, the jobs should automatically restart. You can validate if jobs are still in 'stoped' state by checking http://localhost/jobs/list. If they didn't start automatically, just call http://localhost/jobs/resume-all.
Futbin servers ban your IP address for 6-12 hours. Once you get banned from futbin, application will still work but it will be really slow. If you wish to continue, you can change your IP address (restart modem, use different VPN server) and restart the app.

Disclaimer and Notes

I'm pretty sure this would violate some terms and conditions. Use on your own risk
The requests against fut api and futbin api are limited per minute. The values should be good enough to execute the bot for couple of hours. You can check request stats from http://localhost:9999/stats
In case of temporary ban from fut api, jobs will be stopped automatically. If you are banned from futbin, bot won't make any requests to futbin for next couple of hours. I'm trying all the features from my profile. I generally try it with all quality (including specials). But still there might be weird edge cases which can cause bugs or losses.

Known Bugs

  • Currently, the server gets wrong rating value for special cards. So, parameters such as maxRating is effected. (Nothing wrong with prices.)

Discord

Join this discord server if you have any questions/suggestions. You can also share some feedback for possible enhancements to the bot.

futbot's People

Contributors

dogancana avatar hpbuniat avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

marciocorrrea

futbot's Issues

Fine tuning jobs' execution time per minute values.

Currently when you start 2-3 jobs together, futbin api queue is bloated and time critical tasks become irrelevant.

Possible solution: We should calculate/track how many futbin and fut requests a Job needs and set the initial value accordingly. Whenever a new task is created, Job class should slow down already existing tasks so that we can use full potential of FUTBIN_REQUESTS_PER_SEC and won't create a queue.

Test case: Start below jobs together

  • invest/low-players
  • invest/good-auctions
  • trade-bot/start-selling
    and check /stats for queue lengths.

What i see:

{
  "apiQueues": [
    {
      "cacheHitCount": 34,
      "name": "fut",
      "queueCount": 0,
      "requestCount": 986,
      "requestsPerSecond": "0.5"
    },
    {
      "cacheHitCount": 0,
      "name": "futbin",
      "queueCount": 70,
      "requestCount": 2084,
      "requestsPerSecond": "1.0"
    }
  ],
  "timeSpentMinutes": "35",
  "timeSpentSeconds": "2115"
}

Work for fifa20?

working on fifa 20? if not... any easy changes to do to work?

Bot doesn't buy anything in 2h

First of all, thank you for share this project. I really appreciate it.
This is the result jobs from my bot after 2 hours running.
image
Using LowPlayer or GoodAuction doesn't work for me. GoodAuction got targets but always fail to do de bid. Any ideas?

Cannot get endpoint in extension

I followed all the steps described in https://github.com/dogancana/futbot done
I rebuilt the extension, removed the old one and loaded new one successfully. done
I clicked to the extension and saw Futbot title with my endpoint properly set. no
I set FUTBOT_FUT_API_ENDPOINT_OVERWRITE in .env file as shown from extension no

I have tried both win and macos system. Chrome can success to load extension , then start services.
"Session not copied!. First load Fut Web App with extension undefined"
Clicked extension , but endpoint is always blank, i also cannot set .env
Tired many times and rrrefresh the page many times.

How i can solve the problem ,thanks again!

Error when yarn dev

Cant seem to start the server anymore with the new version?
Did yarn and then yarn dev.
I dont know anything about coding so I'm sorry if this isnt relatated to the script.

Error: Invalid request-speed limit
at Object. futbot-master\lib\api\fut-api\api.ts:21:9)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Module.m._compile \futbot-master\node_modules\ts-node\src\index.ts:439:23)
at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Object.require.extensions.(anonymous function) [as .ts] \futbot-master\node_modules\ts-node\src\index.ts:442:12)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
error Command failed with exit code 1.

prp in futbin xbox queries won't work

Describe the bug
While getting low player invest targets from futbin, the query with xbox prp value gives 404

To Reproduce
Steps to reproduce the behavior:

  1. Start server with xbox profile
  2. See auth token log
  3. Execute task /invest/low-players
  4. See the error 404 on setup targets

Expected behavior
Should remove prp value on xbox

Desktop (please complete the following information):

  • OS: all
  • Platform: Xbox
  • 1.4.0.

error on futbin

i'm getting error 404 on futbin

i tried to visit the page with chrome but 404 again

error: [FUTBIN]: 404 get https://www.futbin.com/20/players?page=0&sort=likes&order=desc&_price=1000-5000 undefined Request failed with status code 404

also player prices also sending valid requests always returns nothing i checked those requests with chrome and python requests and both returned prices

i don't understand node but i guess there is something about the way requests are sent that makes futbin not answer them

bot cannot bid

/invest/low-players works without failure, but with /invest/good-auctions, I always get the following error:

2019-10-18T19:37:19.357Z [FUTBOT] info: [Invest:GoodAuction]: James Rodríguez, (85) bidding for 6500, Expires 55, Buynow 25000
2019-10-18T19:37:25.757Z [FUTBOT] error: [FUT]: 461 put https://utas.external.s2.fut.ea.com/ut/game/fifa20/trade/259659840579/bid {"bid":6500} Request failed with status code 461 "Permission Denied"
2019-10-18T19:37:25.758Z [FUTBOT] error: [Invevst:GoodAuction]: bid failed for James Rodríguez, (85) with bid amount 6500. Reason: undefined

Within two hours uptime, not one single bet got through.

Invest consumables

There should be an investment method similar to invest low players, but instead for consumables.

Trade logic: Invest methods in general depends on wrong valuation of items. In this feature we can have a predefined list of consumable id to price map and search market for 20% profit margin.
Consumables are generally sold/bought with buy now prices. That's why this feature's implementation should be pretty similar to low player investment.

how to start service on macos?

I have load the extension by chrome, click the extension , Your fut endpoint: is blank.
I double clicked the server-macos then....
xxMBP:~ xx$ /Users/xx/Downloads/futbot/server-macos ; exit;
.env file not found. Copy .env.local file as .env file and restart.
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

Chrome extension doesn't work already due to the change of FUT Web APP

I try to install the extension and run bot server, I found the extension never send the authorization data to bot server.

After debugging I found FUT Web APP encapsulates something like XMLHttpRequest thus the AJAX interceptor of extension doesn't work anymore:

UTHttpRequest.prototype.send = function send() {
    if (this._http.readyState > XMLHttpRequest.UNSENT && this._http.readyState < XMLHttpRequest.DONE)
        utils.Debug.Assert(!1, "Attempted to send an HTTP request when it is in the middle of sending.");
    else if (this._http.readyState === XMLHttpRequest.DONE && this.reset(),
    utils.JS.isEmpty(this._url))
        utils.Debug.Assert(!1, "Attempted to send an HTTP request when URL is not set.");
    else {
        var url = this._url + this._urlVariables;
        this._http.open(this._requestType, url, !0),
        this._setDefaultHeaders();
        for (var headers = this._requestHeaders.slice(); headers.length > 0; ) {
            var t = headers.pop();
            this._http.setRequestHeader(t.name, t.value)
        }
        this._cache || this._http.setRequestHeader("Cache-Control", "no-cache"),
        this._timeout > 0 && (this._http.timeout = this._timeout),
        this._http.onreadystatechange = this._onStateChange.bind(this),
        this._requestBody && this._requestType !== enums.HTTPRequestMethod.DELETE ? this._http.send(this._requestBody) : this._http.send()
    }
}

Are there any solution about the interceptor?

Add max rating and amount for selling jobs

I found simply calling http://localhost:9999/trade-bot/start-selling will trying to clear all items in trade pile and sold numbers of players (default: 10) of the club. It causes two problems:

  • Sometimes user may not let the high rating player sold automatically (may make profit by selling in specific time)
  • User cannot sell more players because there is no way to set the amount of the selling job

Thus there is a requirement to add two arguments for the api:

  • max rating: Set the max rating of players which will be sold
  • amount: Set the amount of sold players of the selling job

The expectation like this:
http://localhost:9999/trade-bot/start-selling?maxRating=75&amount=100

Cant read manifest file in stable version

Thanks for taking your time. Cant seem to add the extension to chrome when trying to use the stable version. It say it cant read the manifest. When I edit the manifest file and save it as json instead as a javascript it said:
Manifest is not valid JSON. Line: 1, column: 1, Unexpected token.

Any thoughts?

General improvements for stoping/restarting jobs

Upon critical auth errors or when jobs have nothing left to do, they are being stopped. At this point it's impossible to restart jobs. This should be fixed by creating a resource to manage jobs. Something as follows would suffice:

  • /jobs/list
  • /jobs/stop
  • /jobs/resume
  • /jobs/clear

Also, jobs can be resumed, after receiving a valid auth token.

Sell consumables

There should be a sell consumables task in trader app.

Job should be really similar to start selling job. It should find your consumables, filter out important ones (squad fitness, gold contracts) and sell the rest.

error auth

when i start the server i get this error
(FUTBOT) info:
auth
"XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
undefined

extension not working

i get this error every time and the extension is built and active in chrome

500 get /club?sort=desc&type=player&start=0&count=100 undefined Session not copied!. First load Fut Web App with extension undefined

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.