Extract midi note length in ticks

i’m trying to extract information from a midi file, like
number of tracks in the midi file?
number of phrases in each track?
note names/numbers(including rests) in sequence, in each phrase?
lengths of notes in ticks?
dynamics of notes?