Getting Translation Velocity of an Object Via Scripting

I want to calculate the net translation velocity (in x, y, and z units per frame) of an object at a particular frame via script, so that I can have script-generated projectiles that include that velocity at the frame they become visible (in effect, the frame where they are “fired”). What function should I use? Thanks!

One way to do this would be to get the slope of a graph in the graph editor at a specific frame - does anyone know the function for that?