What I want to do is to be able to code a script which will change a text layer from a Photoshop file for another text in my script.
Is there anyway this can be done? Is there any Photoshop API or something similar?
There's quite a lot you can do with custom scripting. There's a lot to learn and it's got kind of a steep learning curve at first because they have a lot of their own stuff, but it's pretty powerful and flexible.
Adobe's scripts are commonly written in Javascript but can also be written with ActionScript or VB.
Here's a list of resources to get you started:
For the folks who arrive here from a search:
var newText = "Hello there!";
var textLayer = app.activeDocument.artLayers.getByName("layer-name");
textLayer.textItem.contents = newText;