Ahh ok that makes sense, a few questions.
- Are you calling in the state data from the API on the server side or client side?
- Are you only needing to retrieve one state code at a time or a list of all of them.
Basically though it should be pretty simple, assuming you are using something like a dropdown select with a list of states, you could have a server action getting all the state codes from the API and another server action getting all the state codes from the database, Possibly even a single server action if you prefer.
Then add a dynamic select and use a where data formatter to compare your database results with the API results which will return the correct name for the code.
If you are just wanting to replace NY with New York in various areas of text in your document you can do a similar thing with the where data formatters.
I will try give more definitive info when i know how you are using the data and getting the data server side vs client side API calls.