What is OpenGL and DirectX?

Solution
Basically, OpenGL is an open source software to make the games run on hardware.
DirectX is closed and is only developed and changed by MS.

They both try to achieve the same purpose, i.e. they both are APIs. Difference lies in their implementation and not necessarily usage. e.g. UNIX is open source and can be changed by anyone, while Windows or Mac may not. They all are same things in the end: OS. Difference lies in their implementation and not necessarily usage. e.g. some or all of them can be used to run Excel to make or edit spreadsheet. Its not an apple to apple analogy, but I hope you are able to understand what I am trying to say here.

Many games use only DirectX therefore only run on Windows. Many games can use any of them and...
DirectX is essentially a driver plugin that allows for the apps to run on a broad range of hardware, it facilitates a better use of ressources. It is indeed similar to a library. OpenGL follows the same concept but as in its name, it's an open source program that I believe doesn't require a signature. Are you familiar with Visual Studio or Eclipse development ?
 
Very vaguely, I just know what they are.

 
Basically, OpenGL is an open source software to make the games run on hardware.
DirectX is closed and is only developed and changed by MS.

They both try to achieve the same purpose, i.e. they both are APIs. Difference lies in their implementation and not necessarily usage. e.g. UNIX is open source and can be changed by anyone, while Windows or Mac may not. They all are same things in the end: OS. Difference lies in their implementation and not necessarily usage. e.g. some or all of them can be used to run Excel to make or edit spreadsheet. Its not an apple to apple analogy, but I hope you are able to understand what I am trying to say here.

Many games use only DirectX therefore only run on Windows. Many games can use any of them and its entirely possible that they still only run on windows. OpenGL has the facility to make a game run on Linux e.g. or Mac. Similarly, there is another API in the market called Vulkan which is also Open source I believe.

What API to use depends on the usage scenario and possibly the game engine used. eg. ID tech can use Vulkan and Open GL to run games in Unix platforms in addition to windows. While, Assasin's Creed, e.g. works only on Windows since it supports only DirectX AND the developers have not ported it to Linux.
 
Solution

Ok I think I understand, so DirectX and OpenGL help a game take better advantage of a computers graphics potential, and optimize it for a broad range of hardware, but how would someone implement it? What would they add to/ change in their games code to make it work with DirectX or OpenGL?

Lastly, from what I read online about APIs, they allow communication between two pieces of software, what two softwares does DirectX or OpenGL allow communication between.