Introduction : determining which gate is assigned
I assume we are talking about IFR flights with the purpose of passenger travel.
An aircraft, in order to be assigned to a gate, has to be planned and to arrive at an airport.
So let's look at the breakdown of arrival of an aircraft.
First, the airline (operator) has filled a flight plan before the flight occurred and submitted it to the legal authority managing flights in the airspace (Aeronautical Navigation Services -ANS- typically) in order to have clearance to enter the airspace, getting navigation informations and accessing the airport (more on this matter). At this moment, the airport gets informations about the next aircrafts (operator, type of aircraft, passenger, cargo etc.), which will be managed upon arrival.
Secondly, after being handled by Area Control Center (ACC) ATCO (en route flight), the aircraft is routed towards the airport by Approach controllers (APP) which manage the airplane when it flies from en route (high altitude) to the airport (ground); when the aircraft is lined up with the runway a few miles from the airport it is transfered to the tower which manages the operations from this moment (given no go around has been initiated due to runway incursion, landing mishaps etc.) and will most importantly manage ground operations (taxiing, handling take-off and landing sequences etc.).
Once the aircraft has landed and starts taxiing, the tower (TWR) will give directions to the gate it would be assigned, depending on various factors:
- Negotiations with the operator : location of the aircraft at the airport has a price, aprons are more costly than parking the aircraft further from the terminal and being handled by a bus for example.
- Destination and origin of the aircraft : international and regional flight can be handled in different terminals: e.g. in Europe, Schengen area flights are usually handled separately from outside the Schengen area.
- Size of the aircraft : for example A380 are notable for being difficult to maneuver around airports and need specific aprons and some airport have only a few gate that can be assigned to such specific aircraft.
- Available spots : the airports are incredibly busy around noon every day (look at the traffic at a major airport like Heathrow around that time), which means that some spots might be taken and the airport has to accommodate the aircraft at an available gate.
The tower exchange directly with the aircraft (crew or the aircraft itself) via radio or data-link, they give directions and update the gate according to the current available spots. It seems (so I might need more information with somebody more familiar with the matter) that data-link is use in most cases to share informations regarding flight details between ground and aircraft.
All in all, the airport tower decide and manages the gate. The information are stored in an operational database (at the tower or the ANS provider) and are provided to aircrafts, operators and passenger (terminals and online).
Generally speaking, the data is provided to operators via the database and a technical overlay, this can vary depending on the regions. In Europe, operators rely on Eurocontrol Network Manager Operations Centre to exchange informations regarding flight plans, updates of flight plans and different informations regarding operations. I don't have information regarding other regions like North America.
Airport-Collaborative Decision Making
A big topic at the moment for the European airports is the principle of Airport Collaborative Decision Making (ACDM for short) which should improve the quality and reliability of these informations, by sharing information directly from the airport and the NMOC of Eurocontrol.
Though this topic is to large to cover here, it would improve such information being shared between operators, airports, aircrafts etc. and normalise the way information is shared.
As for Flightradar as I pointed out in the comments, they have an explanation of how they work with data.
A final word, it seems that airport API are usually not public, and it can be expected that for examples airlines do not have other's flight information (and gate per se).