Place page number in a Pages document using AppleScript
The pages are stored in ‘pages’. You can iterate over this with ‘repeat’.

tell application "Pages"
    activate
    tell document "Untitled.pages"
        repeat with i from 1 to number of pages
            set thispage to item i of pages
            (* do something
            -- variable i is the page number
            -- variable thispage is the page itself
            *)
        end repeat
    end tell
end tell