Next Track and Library API

does any one know if there exists a command for a “Up Next”.
I have some pretty good modules that i have been working on and slowly trying to perfect and make more robust.
would like to know if there is a way to query what is coming up next on a playlist or a library.

Also is there a way to see through an API command a way to see all the songs and or movies in a library and select them.
Trying to do less on screen and more through a remote interface.

Is there a way to edit the: file.

I want to write a program to query this data base but also i want to edit this to correct metadata and other information.

I downloaded sqllite but cant edit the file info.

does anyone know what kind of db file it is. what data base was it created with?